AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   register_event damage (https://forums.alliedmods.net/showthread.php?t=94516)

stigma 06-12-2009 07:27

register_event damage
 
Hello.

How should i catch the "Damage" event? i'vre tryed using read_data(1) attempting to get the damage done, but without a result.

Edit

NVM, i found out that it is read_data(2) that i should use... Then another question, how come that it does not register all the damage that i do? if i hit a client serveral times, it only register the event few times

Bugsy 06-12-2009 08:52

Re: register_event damage
 
Use Ham_TakeDamage

PHP Code:

RegisterHamHam_TakeDamage "player" "fw_HamTakeDamage" );

public 
fw_HamTakeDamageiVictim iInflictor iAttacker Float:fDamage iBitDamage 
{   




Silencer123 06-12-2009 09:06

Re: register_event damage
 
Quote:

Originally Posted by Bugsy (Post 847127)
Use Ham_TakeDamage

PHP Code:

RegisterHamHam_TakeDamage "player" "fw_HamTakeDamage" );

public 
fw_HamTakeDamageiVictim iInflictor iAttacker Float:fDamage iBitDamage 
{   




Does that support wildcards btw? E.g. instead of "player" use "monster_*" ?

toazron1 06-12-2009 09:13

Re: register_event damage
 
No it doesn't, if you want to hook everything that takes damage you need something like this: http://www.nsmod.org/forums/index.ph...=10179&hl=deli

I don't know of any non-NS equivalent

stigma 06-12-2009 13:35

Re: register_event damage
 
Okay thanks for the response, but as i dont know anything about that ham module, i dident ought to try. But i found out the with the damage event.

Bugsy 06-12-2009 13:47

Re: register_event damage
 
Here's a little example

PHP Code:

new g_MaxPlayers;
#define IsPlayer(%1)  ( 1 <= %1 <= g_MaxPlayers )

//plugin_init()
RegisterHamHam_TakeDamage "player" "fw_HamTakeDamage" );
g_MaxPlayers get_maxplayers();

public 
fw_HamTakeDamageiVictim iInflictor iAttacker Float:fDamage iBitDamage 
{   
    if ( 
IsPlayeriAttacker ) )
     {
        static 
szName33 ];
        
get_user_nameiAttacker szName 32 );
        
client_printiVictim print_chat "You were attacked by %s" szName );
        
//You can block the victim from taking damage with: return HAM_SUPERCEDE;
    
}




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

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