AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Off-Topic (https://forums.alliedmods.net/forumdisplay.php?f=15)
-   -   RegisterHam killed dilema (https://forums.alliedmods.net/showthread.php?t=258040)

Krtola 02-12-2015 08:06

RegisterHam killed dilema
 
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 

:arrow:
PHP Code:




Phant 02-12-2015 08:13

Re: RegisterHam killed dilema
 
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.

Krtola 02-12-2015 08:25

Re: RegisterHam killed dilema
 
So,0 is before and 1 if after?

fysiks 02-12-2015 08:44

Re: RegisterHam killed dilema
 
Quote:

Originally Posted by Krtola (Post 2261477)
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.

Krtola 02-12-2015 08:56

Re: RegisterHam killed dilema
 
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?

Jhob94 02-12-2015 09:09

Re: RegisterHam killed dilema
 
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.

Krtola 02-12-2015 11:29

Re: RegisterHam killed dilema
 
Quote:

Originally Posted by Jhob94 (Post 2261494)
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

fysiks 02-12-2015 20:07

Re: RegisterHam killed dilema
 
Quote:

Originally Posted by Krtola (Post 2261532)
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.

Krtola 02-13-2015 02:03

Re: RegisterHam killed dilema
 
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-

Jhob94 02-13-2015 04:13

Re: RegisterHam killed dilema
 
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.


All times are GMT -4. The time now is 02:58.

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