-Xero Posted March 16, 2018 Share Posted March 16, 2018 Hi, i tried to make a resource to spawn with parachute every time player has death, but dont work, what is wrong ? if i put onplayerspawn, spawns with parachute every time logged in, i only need spawns with parachute only when the player is death, some like OnplayerRespawn ? function onPlayerWasted() giveWeapon(source,getWeaponIDFromName("parachute"),1,true) end addEventHandler("onPlayerWasted",getRootElement(),onPlayerWasted) Link to comment
KaMi Posted March 16, 2018 Share Posted March 16, 2018 2 hours ago, -Xero said: Hi, i tried to make a resource to spawn with parachute every time player has death, but dont work, what is wrong ? if i put onplayerspawn, spawns with parachute every time logged in, i only need spawns with parachute only when the player is death, some like OnplayerRespawn ? function onPlayerWasted() giveWeapon(source,getWeaponIDFromName("parachute"),1,true) end addEventHandler("onPlayerWasted",getRootElement(),onPlayerWasted) Try with this function onPlayerWasted() giveWeapon(source, 46, 1) end addEventHandler("onPlayerWasted",getRootElement(),onPlayerWasted) Link to comment
Zorgman Posted March 16, 2018 Share Posted March 16, 2018 Using onPlayerWasted, set a client check variable to true (e.g. playerNeedsParachute = true). When you spawn the player, give the parachute if your variable is true and set it back to false. Link to comment
[MTA]Weed Posted March 16, 2018 Share Posted March 16, 2018 you need to add it as spawn, because onplayerwasted = player is dead, so on next spawn he will have nothing, you can use something like: function ImWasted() setElementData(source, "state", "Wasted") setTimer(ImGonnaRespawn, 2000, 1, source) end function ImGonnaRespawn(player) if not isElement(player) then return end local element = getElementParent(player) if getElementData(player, "state") ~= "Wasted" then return end repeat until spawnPlayer ( player, -711+math.random(1,5), 957+math.random(5,9), 12.4, 90, math.random(312), 0, 0) fadeCamera(player, true) setCameraTarget(player, player) showChat(player, true) toggleAllControls(player, true, true, true) giveWeapon(player, 46, 1) setElementData(player, "state", "ImAlive") end 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