jakson Posted May 8, 2019 Posted May 8, 2019 hello guys, i was trying to make spawn protection like when player die and respawn in hospital cant use weapons then after the respawn time finish can use it again its works fine but the problem when player respawn in hospital can use weapons without waiting the time sorry for bad english function setPlayerSpawnProtected(player, time) if isElement(player) and getElementType(player) == "player" then setElementAlpha(player, 100) setElementData(player, "SpawnProtected", true) toggleControl(player, "fire", false) rsp[player] = setTimer(function () setElementData(player, "SpawnProtected", false) setElementAlpha(player, 255) toggleControl(player, "fire", true) end, time*1000, 1) return true else return false end end
Dziugasc Posted May 8, 2019 Posted May 8, 2019 there is no Event Handler https://wiki.multitheftauto.com/wiki/OnPlayerWasted
jakson Posted May 8, 2019 Author Posted May 8, 2019 (edited) 26 minutes ago, Dziugasc said: there is no Event Handler https://wiki.multitheftauto.com/wiki/OnPlayerWasted i added it already just the problem in toggleControl addEventHandler("onClientPlayerWasted", localPlayer, function () if getElementData(source, "SpawnProtected") then cancelEvent() end end) Edited May 8, 2019 by jakson
Moderators IIYAMA Posted May 8, 2019 Moderators Posted May 8, 2019 @jakson did you use this function after the event "onPlayerSpawn"?
jakson Posted May 8, 2019 Author Posted May 8, 2019 29 minutes ago, IIYAMA said: @jakson did you use this function after the event "onPlayerSpawn"? nope i didnt
Moderators IIYAMA Posted May 8, 2019 Moderators Posted May 8, 2019 50 minutes ago, jakson said: nope i didnt It might be possible that either by default or by another script the control is enabled. I recommend to use event "onPlayerSpawn" + Put the addEventHandler priority to low. (which is for the onPlayerSpawn event) This will make sure that the control settings are not being overwritten by anything else at serverside. 1
jakson Posted May 8, 2019 Author Posted May 8, 2019 2 hours ago, IIYAMA said: It might be possible that either by default or by another script the control is enabled. I recommend to use event "onPlayerSpawn" + Put the addEventHandler priority to low. (which is for the onPlayerSpawn event) This will make sure that the control settings are not being overwritten by anything else at serverside. still same
Moderators IIYAMA Posted May 8, 2019 Moderators Posted May 8, 2019 1 hour ago, jakson said: still same So what did you do? Else use just a dirty timer or create it clientside. 1 1
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