Jump to content

Spawn player problems


Kors

Recommended Posts

When player, register and enter the server, he spawn in LSPD , how can i fix thet? 
in borph.lua i set my position but thet work when player die, 
 

addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for i,player in ipairs(getElementsByType("player")) do 
            spawn(player) 
        end 
    end 
) 
  
function spawn(player) 
 spawnPlayer ( player, -728.69219970703+math.random(1,1), 1547.8328857422+math.random(1,1),38.977741241455, 90, 71 ) 
    fadeCamera(player, true) 
    setCameraTarget(player, player) 
end 
  
addEventHandler("onPlayerLogin", root, 
    function() 
        spawn(source) 

    end 
) 
  
addEventHandler("onPlayerWasted", root, 
    function() 
                local skin = getElementModel ( source ) 
        setTimer(spawn, 1800, 1, source) 
               setTimer(setElementModel, 1800, 1, source, skin) 
    end 
) 

 

Link to comment

No warnings, no errors,

addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for i,player in ipairs(getElementsByType("player")) do 
            spawn(player) 
        end 
    end 
) 
  
function spawn(player) 
 spawnPlayer ( player, -728.69219970703+math.random(1,1), 1547.8328857422+math.random(1,1),38.977741241455, 90, 71 ) 
    fadeCamera(player, true) 
    setCameraTarget(player, player) 
end 
  
addEventHandler("onPlayerLogin", root, 
    function() 
        spawn(source) 

    end 
) 
  
addEventHandler("onPlayerWasted", root, 
    function() 
                local skin = getElementModel ( source ) 
        setTimer(spawn, 1800, 1, source) 
               setTimer(setElementModel, 1800, 1, source, skin) 
    end 
) 

 

Link to comment

Take this has example which is working add this in any server side script folder or create a new folder !

local randomSpawnTable = {
    { 270.92654418945, -1986.3665771484, 797.52966308594 },
    { 270.92654418945, -1986.3665771484, 797.52966308594 },
    { 270.92654418945, -1986.3665771484, 797.52966308594 }
}
addEventHandler("onPlayerLogin",getRootElement(),
function()
	spawnPlayer(source,unpack(randomSpawnTable[math.random(#randomSpawnTable)]))
	setCameraTarget(source,source)
	setElementModel(source, 312)
	giveWeapon(source,46)
	giveWeapon(source,9)
    giveWeapon(source,25,5000,true)
    giveWeapon(source,28,5000,true)
    giveWeapon(source,31,5000,true)
    giveWeapon(source,22,5000,true)
end)

Removed give weapon if you don't want and replace spawn xyz positions,remove element model & camera target also if you don't want ,this will spawn player after they login !!

Edited by Khadeer143
  • Like 1
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...