Drakath Posted August 27, 2012 Posted August 27, 2012 Why doesn't this script spawn people in the place where it should? Note: It should spawn people after death. Script: -- XYZ coördinates local spawnX = 213.81648254395 local spawnY = 1870.0822753906 local spawnZ = 13.140625 function spawnOnJoin() spawnPlayer(source, 213.81648254395, 1870.0822753906, 13.140625, 0 , 285) fadeCamera(source, true) setCameraTarget(source, source) giveWeapon(source, joinWeapon, joinAmmo) end function spawnOnDead(ammo, killer, weapon, bodypart) end setTimer(spawnPlayer, 3000, 1, source, 213.81648254395, 1870.0822753906, 13.140625, 0, 285) setCameraTarget(source, source) end addEventHandler("onPlayerJoin", getRootElement(), spawnOnJoin) addEventHandler("onPlayerWasted", getRootElement(), spawnOnDead)
denny199 Posted August 27, 2012 Posted August 27, 2012 function spawnOnDead(ammo, killer, weapon, bodypart) end setTimer(spawnPlayer, 3000, 1, source, 213.81648254395, 1870.0822753906, 13.140625, 0, 285) setCameraTarget(source, source) end 2 ends?
Drakath Posted August 27, 2012 Author Posted August 27, 2012 Thanks, I did not noticed it. Is there anything else wrong here because I'm getting crashes and is there anyway to make it don't spawn any skin?
denny199 Posted August 27, 2012 Posted August 27, 2012 Yes there is a way to change the skn look at the syntax spawnPlayer ( player thePlayer, float x, float y, float z, [ int rotation = 0, int skinID = 0, int interior = 0, int dimension = 0, team theTeam = nil ] ) your'e using skin 285 edit: this is a better way: addEventHandler("onResourceStart", resourceRoot, function() for i,player in ipairs(getElementsByType("player")) do spawn(player) end end ) function spawn(player) spawnPlayer(player, 213.81648254395, 1870.0822753906, 13.140625, 0 , 285) fadeCamera(player, true) setCameraTarget(player, player) giveWeapon(player, joinWeapon, joinAmmo) -- btw what is joinweapon and joinammo? end addEventHandler("onPlayerJoin", root, function() spawn(source) end ) addEventHandler("onPlayerWasted", root, function() setTimer(spawn, 3000, 1, source) end )
Drakath Posted August 27, 2012 Author Posted August 27, 2012 I'm asking if there is way to don't spawn the skin not to change. And your script doesn't work every player spawned at one place and lost all weapons...
Castillo Posted August 27, 2012 Posted August 27, 2012 You must store all the player weapons when he dies in a lua table, then loop through them and give them back on spawn.
Drakath Posted August 27, 2012 Author Posted August 27, 2012 I just want to know why the script makes my server crash and is there any way to make it don't spawn the skin...
TAPL Posted August 27, 2012 Posted August 27, 2012 Use this to get the old skin: getElementModel Use this to prevent spawn in same place: math.random Make a script to save the weapon and retrieve it when you need.
Drakath Posted August 27, 2012 Author Posted August 27, 2012 Where do I put: getElementModel ? And why is my server crashing?
TAPL Posted August 27, 2012 Posted August 27, 2012 Where do I put: getElementModel ? And why is my server crashing? change this spawnPlayer(player, 213.81648254395, 1870.0822753906, 13.140625, 0 , 285) to spawnPlayer(player, 213.81648254395, 1870.0822753906, 13.140625, 0 , getElementModel(player))
Drakath Posted August 27, 2012 Author Posted August 27, 2012 Now everyone spawn as CJ. Script: local spawnX = 213.81648254395 local spawnY = 1870.0822753906 local spawnZ = 13.140625 function spawnOnJoin() spawnPlayer(player, 213.81648254395, 1870.0822753906, 13.140625, 0 , getElementModel(player)) fadeCamera(source, true) setCameraTarget(source, source) giveWeapon(source, joinWeapon, joinAmmo) end function spawnOnDead(ammo, killer, weapon, bodypart) setTimer(spawnPlayer, 3000, 1, source, 213.81648254395, 1870.0822753906, 13.140625, 0, getElementModel(player)) setCameraTarget(source, source) end addEventHandler("onPlayerJoin", getRootElement(), spawnOnJoin) addEventHandler("onPlayerWasted", getRootElement(), spawnOnDead)
Drakath Posted August 27, 2012 Author Posted August 27, 2012 Worked, but why does this script makes players crash when reconnecting?
TAPL Posted August 27, 2012 Posted August 27, 2012 Worked, but why does this script makes players crash when reconnecting? i think you need to use a timer with event onPlayerJoin for spawnPlayer.
Drakath Posted August 27, 2012 Author Posted August 27, 2012 So far seems like it's working. Thank you.
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