Jump to content

Extample


xeon17

Recommended Posts

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

Link to comment
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 
) 

Link to comment

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

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...