joaosilva099 Posted July 9, 2015 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. http://i.imgur.com/CSE28MJ.png Don't hesitate to contact me for anything! If I can help, I will for sure! Education is the most powerful weapon which you can use to change the world. - Castillo
joaosilva099 Posted July 11, 2015 Author Posted July 11, 2015 BUMP http://i.imgur.com/CSE28MJ.png Don't hesitate to contact me for anything! If I can help, I will for sure! Education is the most powerful weapon which you can use to change the world. - Castillo
iMr.Dawix~# Posted July 11, 2015 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 ) My E-mails: [ [email protected] ],[ [email protected] ],[ [email protected] ] " Manners Maketh Man " " الأخلاق تصنع الرجل " ░░░░░███████ ]▄▄▄▄▄▄▄▄ BooM ! ▂▄▅█████████▅▄▃▂ ███████████████████]. ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤
joaosilva099 Posted July 11, 2015 Author Posted July 11, 2015 It should only take health if the event was not cancelled and that code does not do that http://i.imgur.com/CSE28MJ.png Don't hesitate to contact me for anything! If I can help, I will for sure! Education is the most powerful weapon which you can use to change the world. - Castillo
GTX Posted July 11, 2015 Posted July 11, 2015 Try putting everything in one code and in one event handler. Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
Lestat Posted July 11, 2015 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")
joaosilva099 Posted July 11, 2015 Author 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 http://i.imgur.com/CSE28MJ.png Don't hesitate to contact me for anything! If I can help, I will for sure! Education is the most powerful weapon which you can use to change the world. - Castillo
iMr.Dawix~# Posted July 12, 2015 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 ) My E-mails: [ [email protected] ],[ [email protected] ],[ [email protected] ] " Manners Maketh Man " " الأخلاق تصنع الرجل " ░░░░░███████ ]▄▄▄▄▄▄▄▄ BooM ! ▂▄▅█████████▅▄▃▂ ███████████████████]. ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤
joaosilva099 Posted July 12, 2015 Author Posted July 12, 2015 Not working, cancelEvent() isn't streamed between resources I think http://i.imgur.com/CSE28MJ.png Don't hesitate to contact me for anything! If I can help, I will for sure! Education is the most powerful weapon which you can use to change the world. - Castillo
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