MAB Posted July 3, 2015 Share Posted July 3, 2015 How to create a table of locations and randomly when the player joins the game...he get spawned a one of the locations of the table?! i tried this but didn't work locations = { [1] = "-375.14301 2192.22534 42.03526", [2] = "-371.94513 2206.79468 42.41978" } function spawn () local x,y,z = math.random (1,2) spawnPlayer ( source,x.y,z ) addEventHandler ( "onPlayerJoin", getRootElement(), spawn) Link to comment
Death Posted July 3, 2015 Share Posted July 3, 2015 try this locations = { { posX = -375.14301, posY = 2192.22534, posZ = 42.03526}, { posX = -371.94513, posY = 2206.79468, posZ = 42.41978}, } function spawn () setElementData(source,"random",math.random(1,2)) rand = getElementData(source,"random") spawnPlayer ( source, locations[rand].posX, locations[rand].posY, locations[rand].posZ ) addEventHandler ( "onPlayerJoin", getRootElement(), spawn) Link to comment
Animan99 Posted July 3, 2015 Share Posted July 3, 2015 local locations = { {x, y, z}, {x, y, z}, {x, y, z} } random = math.random(1, #locations) spawnpoint = locations[random] spawnPlayer(source, spawnpoint[1], spawnpoint[2], spawnpoint[3]) 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