Drakath Posted August 27, 2012 Share 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) Link to comment
denny199 Posted August 27, 2012 Share 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? Link to comment
Drakath Posted August 27, 2012 Author Share 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? Link to comment
denny199 Posted August 27, 2012 Share 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 ) Link to comment
Drakath Posted August 27, 2012 Author Share 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... Link to comment
Castillo Posted August 27, 2012 Share 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. Link to comment
Drakath Posted August 27, 2012 Author Share 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... Link to comment
TAPL Posted August 27, 2012 Share 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. Link to comment
Drakath Posted August 27, 2012 Author Share Posted August 27, 2012 Where do I put: getElementModel ? And why is my server crashing? Link to comment
TAPL Posted August 27, 2012 Share 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)) Link to comment
Drakath Posted August 27, 2012 Author Share 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) Link to comment
TAPL Posted August 27, 2012 Share Posted August 27, 2012 lol, change player in all your code to source. Link to comment
Drakath Posted August 27, 2012 Author Share Posted August 27, 2012 Worked, but why does this script makes players crash when reconnecting? Link to comment
TAPL Posted August 27, 2012 Share 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. Link to comment
Drakath Posted August 27, 2012 Author Share Posted August 27, 2012 So far seems like it's working. Thank you. Link to comment
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