joaosilva099 Posted July 9, 2015 Share Posted July 9, 2015 Hey! I have this script in a resource: addEventHandler("onClientPlayerDamage", localPlayer, function () --if checks... cancelEvent() --end end) And in another resource I have this addEventHandler("onClientPlayerDamage", localPlayer, function (_, _, body, loss) if body == 9 and not wasEventCancelled() then setElementHealth(source, getElementHealth(source)-(loss*0.5) end end) And it's not working... I mean, even if the first resource's event gets cancelled, the second one does not dettect that cancel. I am sure it's cancelling because in another body parts it does not take health. Link to comment
iMr.Dawix~# Posted July 11, 2015 Share Posted July 11, 2015 not tested addEventHandler("onClientPlayerDamage", localPlayer, function (_, _, body, loss) if body == 9 and wasEventCancelled() then ls = tonumber(loss) * 0.5 setElementHealth(source,getElementHealth(source) - ls) end end ) Link to comment
joaosilva099 Posted July 11, 2015 Author Share Posted July 11, 2015 It should only take health if the event was not cancelled and that code does not do that Link to comment
GTX Posted July 11, 2015 Share Posted July 11, 2015 Try putting everything in one code and in one event handler. Link to comment
Lestat Posted July 11, 2015 Share Posted July 11, 2015 addEventHandler("onClientPlayerDamage", localPlayer, function (_, _, body, loss) if body == 9 and not wasEventCancelled() then setElementHealth(source, getElementHealth(source)-(loss*0.5) end end) The "not" means if the event was NOT cancelled. But you want to check if it was. Also you should ensure the second EventHandler gets called after the first always. So use the priority argument (the first one is "normal" by default, so "normal-1" should work flawlessly): addEventHandler("onClientPlayerDamage", localPlayer, function (_, _, body, loss) if body == 9 and wasEventCancelled() then setElementHealth(source, getElementHealth(source)-(loss*0.5) end end, true, "normal-1") Link to comment
joaosilva099 Posted July 11, 2015 Author Share Posted July 11, 2015 I want to give the players more damage if they were hit on the head, so if the damage event got cancelled I don't want the damage to be given... So I must use NOT! And that priority thing isn't working Link to comment
iMr.Dawix~# Posted July 12, 2015 Share Posted July 12, 2015 I want to give the players more damage if they were hit on the head, so if the damage event got cancelled I don't want the damage to be given...So I must use NOT! And that priority thing isn't working <> addEventHandler("onClientPlayerDamage", localPlayer, function (_, _, body, loss) if body == 9 and not wasEventCancelled() then setElementHealth(source, getElementHealth(source) - 1 ) end end ) Link to comment
joaosilva099 Posted July 12, 2015 Author Share Posted July 12, 2015 Not working, cancelEvent() isn't streamed between resources I think 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