WiBox Posted August 3, 2018 Posted August 3, 2018 (edited) Hello, I'm trying to add a damageTimer as if the player was damaged last 20 second he can't use a specific command... damageTimer = {} function test() if ( isTimer(damageTimer) ) then killTimer(damageTimer) end setElementData(source, "damage", "yes") if ( getElementData(source,"damage") == "yes" ) then setElementData(source,"damage", "no") setTimer( function () removeCommandhandler("ldm") end end,15000,1) end addCommandhandler("ldm", LAJDM) end addEventHandler("onPlayerDamage", test) Well, it didn't work shamefully, but I just need to know where are my mistakes... Thanks. " No error in /debugscript 3 " Edited August 3, 2018 by SSKE
Moderators IIYAMA Posted August 4, 2018 Moderators Posted August 4, 2018 Mistakes: 1. You didn't save your timer. + A timer isn't the same as table. 2. If you set the element data to "no" before you set the timer = it has no function at all. You might consider remove it. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
WiBox Posted August 4, 2018 Author Posted August 4, 2018 Can you fix it? Because I don't know how to do any of what you said ..
SycroX Posted August 4, 2018 Posted August 4, 2018 damageTimer = {} addEventHandler("onPlayerDamage", root, function() if not isTimer(damageTimer[source]) then removeCommandHandler("ldm") damageTimer[source] = setTimer(function(source) damageTimer[source] = nil addCommandHandler("ldm") end, 20000, 1, source) end end ) Chillin' with some demons, satans and vamps
SycroX Posted August 4, 2018 Posted August 4, 2018 32 minutes ago, SSKE said: Oh, I see. Thanks I appreciate that np Chillin' with some demons, satans and vamps
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