Raised This Month: $ Target: $400
 0% 

prevent a Ham registered event from going through


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
striker07
Veteran Member
Join Date: Mar 2012
Location: Solar System/Earth/Belgi
Old 01-04-2014 , 18:55   prevent a Ham registered event from going through
Reply With Quote #1

RegisterHam(Ham_TakeDamage, "player", "player_hurt_pre", 1)

as you can see, i hooked Ham_TakeDamage
when this fires and my condition to block the event from continuing its normal proces is met i return HAM_SUPERCEDE.

Unfortunatly this doesnt work and damage still goes through and the player still hits his target.
I need a full stop, how could i do that?
__________________

Working on:
[CSGO/CSS] Mmorpg - an extensive XP/level modulair platform
Progress: [♣♣♣♣♣♣♣|♣♣♣]
striker07 is offline
matsi
Thinkosaur
Join Date: Sep 2006
Old 01-04-2014 , 20:04   Re: prevent a Ham registered event from going through
Reply With Quote #2

Code:
/**  * Stops a ham forward from triggering.  * Use the return value from RegisterHam as the parameter here!  *  * @param fwd         The forward to stop.  */ native DisableHamForward(HamHook:fwd); /**  * Starts a ham forward back up.  * Use the return value from RegisterHam as the parameter here!  *  * @param fwd         The forward to re-enable.  */ native EnableHamForward(HamHook:fwd);
__________________

Accepting all kinds of requests via private message.

Last edited by matsi; 01-04-2014 at 20:07.
matsi is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-04-2014 , 21:01   Re: prevent a Ham registered event from going through
Reply With Quote #3

Quote:
Originally Posted by striker07 View Post
RegisterHam(Ham_TakeDamage, "player", "player_hurt_pre", 1)

as you can see, i hooked Ham_TakeDamage
when this fires and my condition to block the event from continuing its normal proces is met i return HAM_SUPERCEDE.

Unfortunatly this doesnt work and damage still goes through and the player still hits his target.
I need a full stop, how could i do that?
You can't stop a function when you hook it as post (like you are doing). You have to hook it as a prehook (aka post=0 or omit the last argument). So, if you hook it correctly, HAM_SUPERCEDE will work.

Quote:
Originally Posted by matsi View Post
Code:
/**  * Stops a ham forward from triggering.  * Use the return value from RegisterHam as the parameter here!  *  * @param fwd         The forward to stop.  */ native DisableHamForward(HamHook:fwd); /**  * Starts a ham forward back up.  * Use the return value from RegisterHam as the parameter here!  *  * @param fwd         The forward to re-enable.  */ native EnableHamForward(HamHook:fwd);
He doesn't want to disable the forward, he wants to act on the event.
__________________

Last edited by fysiks; 01-04-2014 at 21:03.
fysiks is offline
matsi
Thinkosaur
Join Date: Sep 2006
Old 01-04-2014 , 21:14   Re: prevent a Ham registered event from going through
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
He doesn't want to disable the forward, he wants to act on the event.
Well i thought about that because of the last sentence:

Quote:
Originally Posted by striker07 View Post
I need a full stop, how could i do that?
To be honest i don't really understand what he is trying to explain.
__________________

Accepting all kinds of requests via private message.
matsi is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-04-2014 , 22:53   Re: prevent a Ham registered event from going through
Reply With Quote #5

Quote:
Originally Posted by matsi View Post
To be honest i don't really understand what he is trying to explain.
When someone is taking damage, he is checking to see if he wants the damage to actually be inflicted on that person. So, for example, if you wanted to make someone invincible, you would check if the person that is taking damage is that person. If yes, then you supercede the event so that they don't take any damage.
__________________
fysiks is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-05-2014 , 05:06   Re: prevent a Ham registered event from going through
Reply With Quote #6

This is wrong : RegisterHam(Ham_TakeDamage, "player", "player_hurt_pre", 1)

Already stated by fysiks but you may understand better like this :


RegisterHam(Ham_TakeDamage, "player", "player_hurt_pre", 0) <- you can stop this one because you hook it before it is executed


RegisterHam(Ham_TakeDamage, "player", "player_hurt_post", 1) <- you can't stop this one because you hook it after it has been executed
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
matsi
Thinkosaur
Join Date: Sep 2006
Old 01-05-2014 , 06:13   Re: prevent a Ham registered event from going through
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
When someone is taking damage, he is checking to see if he wants the damage to actually be inflicted on that person. So, for example, if you wanted to make someone invincible, you would check if the person that is taking damage is that person. If yes, then you supercede the event so that they don't take any damage.
Its funny. Reading it late last night it didn't make any sense but today after sleeping the first post makes sense to me when reading it again now.
__________________

Accepting all kinds of requests via private message.

Last edited by matsi; 01-05-2014 at 06:13.
matsi is offline
striker07
Veteran Member
Join Date: Mar 2012
Location: Solar System/Earth/Belgi
Old 01-05-2014 , 07:07   Re: prevent a Ham registered event from going through
Reply With Quote #8

Quote:
Originally Posted by fysiks View Post
When someone is taking damage, he is checking to see if he wants the damage to actually be inflicted on that person. So, for example, if you wanted to make someone invincible, you would check if the person that is taking damage is that person. If yes, then you supercede the event so that they don't take any damage.
Thats exactly what i tried to explain .
Thanks for pointing out that i need to use 0 for pre and 1 for post, the discription sais the exact opposite .

Also it's good to know that you guy's are still active here, you guys are like legends when it comes to this

Quote:
Originally Posted by matsi View Post
Its funny. Reading it late last night it didn't make any sense but today after sleeping the first post makes sense to me when reading it again now.
it was late for me aswell yesterday when i posted my first message, i totally understand your pain
__________________

Working on:
[CSGO/CSS] Mmorpg - an extensive XP/level modulair platform
Progress: [♣♣♣♣♣♣♣|♣♣♣]

Last edited by striker07; 01-05-2014 at 07:10.
striker07 is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 01-05-2014 , 07:12   Re: prevent a Ham registered event from going through
Reply With Quote #9

Quote:
Originally Posted by striker07 View Post
the discription sais the exact opposite
Why do people always think that? 0 means false and 1 means true. Therefore by putting 0, you are saying to NOT hook it as post.
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-05-2014 , 08:53   Re: prevent a Ham registered event from going through
Reply With Quote #10

Quote:
Originally Posted by striker07 View Post
the discription sais the exact opposite
The description is correct :

Quote:
* @param post Whether or not to forward this in post.

native HamHook:RegisterHam(Ham:function, const EntityClass[], const Callback[], Post=0);
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:37.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode