Raised This Month: $ Target: $400
 0% 

Ham return types question.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-07-2009 , 18:42   Ham return types question.
Reply With Quote #1

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.
fysiks is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-07-2009 , 18:44   Re: Ham return types question.
Reply With Quote #2

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.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-07-2009 , 19:02   Re: Ham return types question.
Reply With Quote #3

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.

Last edited by fysiks; 01-07-2009 at 19:32. Reason: clarify
fysiks is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 01-07-2009 , 20:29   Re: Ham return types question.
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
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
__________________

Community / No support through PM
danielkza is offline
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 01-07-2009 , 21:58   Re: Ham return types question.
Reply With Quote #5

In Ham case you must return anything nomather what (or else there is a possibility that function wont work - try takedamage for example).
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.
MPNumB is offline
Send a message via Skype™ to MPNumB
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 01-07-2009 , 22:07   Re: Ham return types question.
Reply With Quote #6

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.
__________________

Community / No support through PM
danielkza is offline
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 01-07-2009 , 22:17   Re: Ham return types question.
Reply With Quote #7

I once tested Ham_TakeDamage. When I didn't return anything - damage wasn't given. I'm telling you.
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.
MPNumB is offline
Send a message via Skype™ to MPNumB
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 01-07-2009 , 22:28   Re: Ham return types question.
Reply With Quote #8

Quote:
Originally Posted by MPNumB View Post
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")

__________________

Community / No support through PM
danielkza is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 01-07-2009 , 22:31   Re: Ham return types question.
Reply With Quote #9

Quote:
Originally Posted by MPNumB View Post
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.
__________________
Bad_Bud 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 09:15.


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