Gamesnert Posted January 30, 2010 Share Posted January 30, 2010 rootElement = getRootElement () players = getElementsByType("player") -- <---- function startMap( startedMap ) mapRoot = getResourceRootElement( startedMap ) triggerEvent ( "PlayerSpawn", rootElement, players ) -- <---- end Note how you're sending a table of players to a function that will only accept a single player argument. spawnPlayer simply doesn't like this, and when scripting functions don't like something, they won't give you the desired results. To fix this we need to split the table and trigger the event for every player. Much like: for index, player in ipairs(players) do -- For every entry in indexed table "players", store the index in variable "index", and the value in variable "player" triggerEvent ( "PlayerSpawn", rootElement, player ) -- Trigger event "PlayerSpawn" with source "rootElement" and 1st argument is the value of variable "player" end -- End of the code that has to be executed for every entry Note: You can remove the "--" and the text behind it, however leaving them there causes no harm. They're comments, and Lua will just skip these when the script executes. I hope that'll fix it for you. Link to comment
Loren_ita Posted January 31, 2010 Author Share Posted January 31, 2010 Thanks. Now the script don't have error but it don't spawn me. i don't understand... I write here the script for any help: --RTKI GAMEMODE by Loren_ita rootElement = getRootElement () players = getElementsByType("player") function startMap( startedMap ) mapRoot = getResourceRootElement( startedMap ) for index, player in ipairs(players) do -- For every entry in indexed table "players", store the index in variable "index", and the value in variable "player" triggerEvent( "PlayerSpawn", rootElement, player ) -- Trigger event "PlayerSpawn" with source "rootElement" and 1st argument is the value of variable "player" end end addEvent ( "PlayerSpawn", true ) function joinHandler( thePlayer ) local SpawnElements = getElementsByType ( "spawnpoint", mapRoot ) local value = SpawnElements[math.random(#SpawnElements)] local x = tonumber( getElementData( value, "posX" ) ) local y = tonumber( getElementData( value, "posY" ) ) local z = tonumber( getElementData( value, "posZ" ) ) local r = tonumber( getElementData( value, "rotZ" ) or 0 ) repeat until spawnPlayer ( thePlayer , x, y, z, r, math.random (0,288)) end function respawndied() setTimer( joinHandler, 1800, 1, source ) end function spawnJoin() setTimer( joinHandler, 1800, 1, source ) end addEventHandler ("PlayerSpawn", rootElement, joinHandler) addEventHandler ("onGamemodeMapStart", getRootElement(), startMap) addEventHandler ("onPlayerWasted", getRootElement(), respawndied ) addEventHandler ("onPlayerJoin", getRootElement(), spawnJoin ) Link to comment
Gamesnert Posted January 31, 2010 Share Posted January 31, 2010 I also notice you're forgetting 2 camera related things: - Camera is faded to black by default - Camera isn't aiming at the player by default To fix the above 2 "problems", use: fadeCamera(thePlayer,true) -- The player can see now, but it's kind of in a useless spot setCameraTarget(thePlayer,thePlayer) -- The camera is now following the player, which is a lot more useful Link to comment
Loren_ita Posted January 31, 2010 Author Share Posted January 31, 2010 Yes, i forget it because i don't know this function. Very thanks. Now i try. Work fine! Thansk, realy. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now