AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ham return types question. (https://forums.alliedmods.net/showthread.php?t=83322)

fysiks 01-07-2009 18:42

Ham return types question.
 
Do I only need to use the "Ham" return constants in functions that are handling the RegisterHam forward?

Does this answer change if "post" is specified in RegisterHam since you wouldn't be able to stop the forwarded function by then anyway? (i.e. If I use "post" in RegisterHam can I use PLUGIN_HANDLED and PLUGIN_CONTINUE for the the function handling the forward instead?)

Thanks.

Exolent[jNr] 01-07-2009 18:44

Re: Ham return types question.
 
Use the return values given with each include.
If you use a forward from HamSandwich, use HAM_* returns.
If you use a forward from Fakemeta, use FMRES_* returns.
Otherwise, use PLUGIN_* returns.

fysiks 01-07-2009 19:02

Re: Ham return types question.
 
Another question:

I switched from register_event("DeathMsg", "player_death", "a") to RegisterHam(Ham_Killed, "player", "ham_player_death", 1). In player_death() I used PLUGIN_CONTINUE for all my return values. From what I read in the constant include files I should convert all PLUGIN_CONTINUEs to HAM_HANDLED?

I was told that PLUGIN_HANDLED in the register_event case would cause the death to be unhookable by other plugins.

danielkza 01-07-2009 20:29

Re: Ham return types question.
 
Quote:

Originally Posted by fysiks (Post 740121)
Another question:

I switched from register_event("DeathMsg", "player_death", "a") to RegisterHam(Ham_Killed, "player", "ham_player_death", 1). In player_death() I used PLUGIN_CONTINUE for all my return values. From what I read in the constant include files I should convert all PLUGIN_CONTINUEs to HAM_HANDLED?

I was told that PLUGIN_HANDLED in the register_event case would cause the death to be unhookable by other plugins.

You should not compare the returns by ther value, but for their meanings

In your case, a direct comparison would be:
PLUGIN_CONTINUE = HAM_IGNORED
PLUGIN_HANDLED = HAM_SUPERCEDE

MPNumB 01-07-2009 21:58

Re: Ham return types question.
 
In Ham case you must return anything nomather what (or else there is a possibility that function wont work - try takedamage for example).

danielkza 01-07-2009 22:07

Re: Ham return types question.
 
Quote:

Originally Posted by ham_const.inc
* Return these from hooks to disable calling the target function.
* Numbers match up with fakemeta's FMRES_* for clarity. They are interchangable.
* 0 (or no return) is also interpretted as HAM_IGNORED.
*/

sawce disagrees with you.

MPNumB 01-07-2009 22:17

Re: Ham return types question.
 
I once tested Ham_TakeDamage. When I didn't return anything - damage wasn't given. I'm telling you.

danielkza 01-07-2009 22:28

Re: Ham return types question.
 
Quote:

Originally Posted by MPNumB (Post 740191)
I once tested Ham_TakeDamage. When I didn't return anything - damage wasn't given. I'm telling you.

Just tested this code: works fine, prints the message, damage is taken normally.

PHP Code:

#include <amxmodx>
#include <hamsandwich>

public plugin_init()
{
    
RegisterHam(Ham_TakeDamage"player""hamTakeDamage"0)
}

public 
hamTakeDamage(thisidinflictoridattackerFloat:damagedamagebits)
{
    if(
is_user_connected(this))
        
client_print(thisprint_chat"TakeDamage")



Bad_Bud 01-07-2009 22:31

Re: Ham return types question.
 
Quote:

Originally Posted by MPNumB (Post 740191)
I once tested Ham_TakeDamage. When I didn't return anything - damage wasn't given. I'm telling you.

Possibly could have been an older version.


All times are GMT -4. The time now is 09:15.

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