lolman Posted July 8, 2015 Share Posted July 8, 2015 Hi, I've a problem with my code... I want to set a timer on the onClientPlayerDamage part but it doesnt work very well... If someone could help me with setting a timer. I want that you will have 10 seconds protection and then you are damagable. function protect() if getElementAlpha(localPlayer) == 255 then setElementAlpha(localPlayer, 180) setElementData(localPlayer, "inv", true) end end addEventHandler("onClientPlayerSpawn", getRootElement(), protect) function() if getElementData(localPlayer, "inv") == true then cancelEvent() setElementData(localPlayer, "gmm", true) end end addEventHandler("onClientPlayerDamage", getRootElement(), cancelEvent) function seta() if getElementAlpha(localPlayer) == 180 then setElementAlpha(localPlayer, 255) end end setTimer(seta, 10000, 1) Link to comment
Calculador Posted July 8, 2015 Share Posted July 8, 2015 You don't defined the function in event "onPlayerDamage" but test it. function protect() if getElementAlpha(localPlayer) == 255 then setElementAlpha(localPlayer, 180) setElementData(localPlayer, "inv", true) setTimer(setElementData, 10000, 1, localPlayer, "inv", false) setTimer(setElementAlpha, 10000, 1, localPlayer, 255) end end addEventHandler("onClientPlayerSpawn", getRootElement(), protect) function CancelEvent () if getElementData(localPlayer, "inv") == true then cancelEvent() end end addEventHandler("onClientPlayerDamage", getRootElement(), CancelEvent) Link to comment
lolman Posted July 9, 2015 Author Share Posted July 9, 2015 Wow dude, you're amazing ! thank you man Link to comment
Calculador Posted July 9, 2015 Share Posted July 9, 2015 Wow dude, you're amazing ! thank you man you're welcome 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