Raised This Month: $ Target: $400
 0% 

RegisterHam killed dilema


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 02-12-2015 , 08:06   RegisterHam killed dilema
Reply With Quote #1

What is the difference:
PHP Code:
RegisterHam(Ham_Killed"player""OnPlayerKilled"0
and this

PHP Code:
RegisterHam(Ham_Killed"player""OnPlayerKilled"1
You will see that I just changed
PHP Code:
 0 

PHP Code:

Krtola is offline
Send a message via Skype™ to Krtola
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 02-12-2015 , 08:13   Re: RegisterHam killed dilema
Reply With Quote #2

Quote:
/**
* Hooks the virtual table for the specified entity class.
* An example would be: RegisterHam(Ham_TakeDamage, "player", "player_hurt");
* Look at the Ham enum for parameter lists.
*
* @param function The function to hook.
* @param EntityClass The entity classname to hook.
* @param callback The forward to call.
* @param post Whether or not to forward this in post.
* @return Returns a handle to the forward. Use EnableHamForward/DisableHamForward to toggle the forward on or off.
*/
native HamHook:RegisterHam(Ham:function, const EntityClass[], const Callback[], Post=0);
Call function before or after event.
Phant is offline
Send a message via ICQ to Phant
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 02-12-2015 , 08:25   Re: RegisterHam killed dilema
Reply With Quote #3

So,0 is before and 1 if after?
Krtola is offline
Send a message via Skype™ to Krtola
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-12-2015 , 08:44   Re: RegisterHam killed dilema
Reply With Quote #4

Quote:
Originally Posted by Krtola View Post
So,0 is before and 1 if after?
Yes. If it is hooked with post, you can't change the event itself and can only react to it.
__________________
fysiks is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 02-12-2015 , 08:56   Re: RegisterHam killed dilema
Reply With Quote #5

For example:
PHP Code:
public OnPlayerKilled(id)
{
    
remove_task(id TASK_AURA)
    
has_aura[id] = false

In this case I need to put 0,or also can 1,and will have the same result or not?
Krtola is offline
Send a message via Skype™ to Krtola
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 02-12-2015 , 09:09   Re: RegisterHam killed dilema
Reply With Quote #6

In this case you can use whatever you want.
Pre is mostly to act for block kill and let player kept alive for example.
Pre = Player isnt dead yet, but is going to die if you dont do anything
Post = Player is dead already

I recommend you to use post, but pre should work just fine too, depending if other plugin blocks the death.
__________________
Jhob94 is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 02-12-2015 , 11:29   Re: RegisterHam killed dilema
Reply With Quote #7

Quote:
Originally Posted by Jhob94 View Post
In this case you can use whatever you want.
Pre is mostly to act for block kill and let player kept alive for example.
Pre = Player isnt dead yet, but is going to die if you dont do anything
Post = Player is dead already

I recommend you to use post, but pre should work just fine too, depending if other plugin blocks the death.
ok,now understand.

I suppose this is for all functions(FM_UpdateClientData,FM_CmdStart etc...)-0 is always pre,and 1 is always post

Last edited by Krtola; 02-12-2015 at 11:33.
Krtola is offline
Send a message via Skype™ to Krtola
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-12-2015 , 20:07   Re: RegisterHam killed dilema
Reply With Quote #8

Quote:
Originally Posted by Krtola View Post
ok,now understand.

I suppose this is for all functions(FM_UpdateClientData,FM_CmdStart etc...)-0 is always pre,and 1 is always post
No. "FM" = Fakemeta. "Ham" = Hamsandwich [module]. To change the Ham_Killed event (or any Ham event), you have to use the Ham functions.
__________________
fysiks is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 02-13-2015 , 02:03   Re: RegisterHam killed dilema
Reply With Quote #9

I know that,but in this example:
PHP Code:
register_forward(FM_UpdateClientData"fw_UpdateClientData_Post"1
Number 1 means -after-

I want to say,when we see 1 or 0 at the end of certain functions,these numbers always have meaning -before- -after-
Krtola is offline
Send a message via Skype™ to Krtola
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 02-13-2015 , 04:13   Re: RegisterHam killed dilema
Reply With Quote #10

Pre is always before, post is always after.
Some functions may use 1 as post, but i think that amxx functions use always 0 as post and 1 as pre. The best way that you have to see it is by opening the include file and check by yourself.
__________________
Jhob94 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 02:59.


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