Jump to content

Help: Spawn on Player Login Problem


Hadif

Recommended Posts

Hey guys, I have made a script that spawn a player when player logs in. But, it is not working and the debug console not show any errors. Any help will be appreciate, thank you!

Script:

addEventHandler ( "onPlayerLogin", getRootElement ( ), 
    function ( ) 
        setPlayerSpawn ( ) 
    end 
) 
  
function setPlayerSpawn ( ) 
    setPlayerSpawnPosition ( source ) 
end 
  
function setPlayerSpawnPosition ( player ) 
    local positions = { 
    { -894.90002, 1963, 0.6, 14 }, 
    { -893.40002, 1963.4, 60.6, 14 }, 
    { -891.79999, 1963.8, 60.6, 14 } 
    } 
    local randomize = math.random ( 1, #positions ) 
    spawnPlayer ( player, positions [ randomize ] [ 1 ], positions [ randomize ] [ 2 ], positions [ randomize ] [ 3 ], positions [ randomize ] [ 4 ] ) 
end 

Link to comment

source is not defined in setPlayerSpawn, you need to add it as an argument.

addEventHandler ( "onPlayerLogin", getRootElement ( ), 
    function ( ) 
        setPlayerSpawn (source ) 
    end 
) 
  
function setPlayerSpawn ( player ) 
    setPlayerSpawnPosition ( player ) 
end 
  
function setPlayerSpawnPosition ( player ) 
    local positions = { 
    { -894.90002, 1963, 0.6, 14 }, 
    { -893.40002, 1963.4, 60.6, 14 }, 
    { -891.79999, 1963.8, 60.6, 14 } 
    } 
    local randomize = math.random ( 1, #positions ) 
    spawnPlayer ( player, positions [ randomize ] [ 1 ], positions [ randomize ] [ 2 ], positions [ randomize ] [ 3 ], positions [ randomize ] [ 4 ] ) 
end 

Link to comment
source is not defined in setPlayerSpawn, you need to add it as an argument.
addEventHandler ( "onPlayerLogin", getRootElement ( ), 
    function ( ) 
        setPlayerSpawn (source ) 
    end 
) 
  
function setPlayerSpawn ( player ) 
    setPlayerSpawnPosition ( player ) 
end 
  
function setPlayerSpawnPosition ( player ) 
    local positions = { 
    { -894.90002, 1963, 0.6, 14 }, 
    { -893.40002, 1963.4, 60.6, 14 }, 
    { -891.79999, 1963.8, 60.6, 14 } 
    } 
    local randomize = math.random ( 1, #positions ) 
    spawnPlayer ( player, positions [ randomize ] [ 1 ], positions [ randomize ] [ 2 ], positions [ randomize ] [ 3 ], positions [ randomize ] [ 4 ] ) 
end 

Are you sure? Ill try this later. Anyway, thanks for your help.

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...