xeon17 Posted February 6, 2014 Posted February 6, 2014 How to crate a spawn table , an simple spawn table whitch spawn player on 5 locations when they spawn ? i understand spawnPlayer , but the table not help me guys
ViRuZGamiing Posted February 6, 2014 Posted February 6, 2014 you can do a table with tables inside; spawnTable = { [1] = {2886, 217, 122, 1003.9, 0, 0, 0}, [2] = {1508, 213.89999, 122.5, 1003.90002, 0, 0, 90}, [3] = {9131, 214, 122.4, 1003.40002, 0, 0, 0}, [4] = {9131, 214, 122.4, 1005.66998, 0, 0, 0}, [5] = {9131, 217, 122.3, 1005.66998, 0, 0, 0}, } for i=1,5 do local spawnpoint = spawnPlayer(math.random(spawnTable[i])) end Not tested
myonlake Posted February 6, 2014 Posted February 6, 2014 you can do a table with tables inside; spawnTable = { [1] = {2886, 217, 122, 1003.9, 0, 0, 0}, [2] = {1508, 213.89999, 122.5, 1003.90002, 0, 0, 90}, [3] = {9131, 214, 122.4, 1003.40002, 0, 0, 0}, [4] = {9131, 214, 122.4, 1005.66998, 0, 0, 0}, [5] = {9131, 217, 122.3, 1005.66998, 0, 0, 0}, } for i=1,5 do local spawnpoint = spawnPlayer(math.random(spawnTable[i])) end Not tested Umm, no. That's just wrong. You're looping through the array and causing the player to spawn in five places instead of a random place once. You didn't even define a player, and that random number part wouldn't work neither, because you need the count of the array, not the array values. Server-side local spawnTable = { -- x, y, z, rotation, skin id, interior, dimension { 0, 0, 3, 0, 0, 0, 0 }, { 5, 5, 3, 90, 280, 0, 0 }, { 10, 10, 3, 180, 287, 0, 0 }, { 15, 15, 3, 270, 18, 0, 0 }, { 20, 20, 3, 0, 12, 0, 0 } } addEventHandler( "onPlayerJoin", root, function( ) local spawnID = math.random( 1, #spawnTable ) spawnPlayer( source, unpack( spawnTable[ spawnID ] ) ) outputChatBox( "You spawned in spawn point " .. spawnID .. ".", source, 20, 245, 20, false ) end )
xeon17 Posted February 6, 2014 Author Posted February 6, 2014 Thanks for the help guys , but something is wrong , i spawn on 5 place in 4 second and get over 5 outchatbox or more. I changed the event handler on ''onPlayerSpawn'' and deleted the outchatbox , but it spawn me on all place in 2-5 seconds when i spawn
myonlake Posted February 6, 2014 Posted February 6, 2014 You cannot use onPlayerSpawn. It will spawn you indefinitely. You have to use something else, like in my code I used onPlayerJoin.
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