AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Put Ham_TookDamage in a function (https://forums.alliedmods.net/showthread.php?t=95811)

TitANious 06-27-2009 13:33

Put Ham_TookDamage in a function
 
I need to get Ham_TookDamage activated ONLY if they bought from a menu.
PHP Code:

#include <amxmodx>
#include <cstrike>
#include <fun>
#include <hamsandwich>

public plugin_init( )
{
    
register_plugin"Damage","1.0","TitANious" )

    
RegisterHamHam_TakeDamage"player""Player_TookDamage" )
}

public 
Player_TookDamageiVictimiInflictoriAttackerFloat:DamageiDamage_type )
{
    if( !
is_user_aliveiAttacker ) || cs_get_user_teamiAttacker ) == cs_get_user_teamiVictim ) )
        return 
PLUGIN_HANDLED;
        
    if( ( 
iDamage_type & ( 1<<) ) )
    {
        
set_user_healthiAttackerfloatroundFloat:get_user_healthiAttacker ) + Damage ) )
        
client_printiAttackerprint_chat"You got %d extra hp for damaging"Damage )
    }
    return 
PLUGIN_CONTINUE



Arkshine 06-27-2009 13:35

Re: Put Ham_TookDamage in a function
 
Use a var since you can't (un)activate depending a player. (because registered by class)

TitANious 06-27-2009 13:39

Re: Put Ham_TookDamage in a function
 
What you mean by using a var? (What is a var, like Cvar?)
I thought of using a bool. Like:
PHP Code:

if( GotSomething == true )



SnoW 06-27-2009 14:02

Re: Put Ham_TookDamage in a function
 
Ye, boolean is a one type of a var. Var means variable.

xPaw 06-27-2009 14:14

Re: Put Ham_TookDamage in a function
 
You cant return PLUGIN_* on Ham forwards check ham_const.inc

alan_el_more 06-27-2009 14:42

Re: Put Ham_TookDamage in a function
 
try this

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <fun>
#include <hamsandwich>

public plugin_init( )
{
    
register_plugin"Damage","1.0","TitANious" )

    
RegisterHamHam_TakeDamage"player""Player_TookDamage" )
}

public 
Player_TookDamageiVictimiInflictoriAttackerFloat:DamageiDamage_type )
{
    if( !
is_user_aliveiAttacker ) || cs_get_user_teamiAttacker ) == cs_get_user_teamiVictim ) )
        return 
HAM_IGNORED;
        
    if( ( 
iDamage_type & ( 1<<) ) )
    {
        
set_user_healthiAttackerfloatroundFloat:get_user_healthiAttacker ) + Damage ) )
        
client_printiAttackerprint_chat"You got %d extra hp for damaging"Damage )
    }
    return 
HAM_IGNORED



TitANious 06-27-2009 14:45

Re: Put Ham_TookDamage in a function
 
It was not because it wasen't working :)


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

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