Jump to content

cancelEvent not being streamed ??


Recommended Posts

Posted

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.

350x20_FFFFFF_FFFFFF_000000_000000.png

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

Posted

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:

" Manners Maketh Man "

" الأخلاق تصنع الرجل "

░░░░░███████ ]▄▄▄▄▄▄▄▄ BooM !

▂▄▅█████████▅▄▃▂

███████████████████].

◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

Posted

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
Posted
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") 

Posted

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

350x20_FFFFFF_FFFFFF_000000_000000.png

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

Posted
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

<> :fadein:

addEventHandler("onClientPlayerDamage", localPlayer, function (_, _, body, loss) 
     if body == 9 and not wasEventCancelled() then 
          setElementHealth(source, getElementHealth(source) - 1 ) 
     end 
end 
) 

My E-mails:

" Manners Maketh Man "

" الأخلاق تصنع الرجل "

░░░░░███████ ]▄▄▄▄▄▄▄▄ BooM !

▂▄▅█████████▅▄▃▂

███████████████████].

◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...