AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Detect if a player has made damage to another player (https://forums.alliedmods.net/showthread.php?t=251593)

Hackerpcs 11-15-2014 17:29

Detect if a player has made damage to another player
 
As title says, how do I do it?

YamiKaitou 11-15-2014 17:36

Re: Detect if a player has made damage to another player
 
Hook Ham_TakeDamage

Hackerpcs 11-15-2014 18:15

Re: Detect if a player has made damage to another player
 
Quote:

Originally Posted by YamiKaitou (Post 2224666)
Hook Ham_TakeDamage

Some more details? I'm not experienced with Hamsandwich.

YamiKaitou 11-15-2014 18:20

Re: Detect if a player has made damage to another player
 
Search

Hackerpcs 11-15-2014 18:46

Re: Detect if a player has made damage to another player
 
PHP Code:

new bool:bGivenDamage33 ]

// plugin_init()
RegisterHam(Ham_TakeDamage"player""fw_takedamage"

public 
fw_takedamage(victiminflictorattackerFloat:damagebits)
{
    if (
attacker == victim)
    {
        return 
HAM_IGNORED;
    }

    if (
attacker == inflictor)
    {
        
bGivenDamage[attacker]=true;
    }

    return 
HAM_IGNORED;
}

public 
blabla(id)
{
    if(
bGivenDamage[id])
    {
        
client_print(idprint_center"You have inflicted damage");
    }


Is this correct?

fysiks 11-15-2014 19:13

Re: Detect if a player has made damage to another player
 
Quote:

Originally Posted by Hackerpcs (Post 2224682)
Is this correct?

Did you test it?

zmd94 11-15-2014 20:13

Re: Detect if a player has made damage to another player
 
Just learn from this code: https://forums.alliedmods.net/showthread.php?t=88577

avril-lavigne 11-16-2014 02:21

Re: Detect if a player has made damage to another player
 
better use offset

PHP Code:

new const m_lastDamageAmount 334
#define damag(%0) get_pdata_int(%0,m_lastDamageAmount,5)


register as Post

 RegisterHam
(Ham_TakeDamage "player" "TakeDamage" ); 

public 
TakeDamagevic iInflictor att Float:dmg DmgBits )
server_print("damage done to victim is  %.2f"damag(vic) ) 


RateX 11-16-2014 05:54

Re: Detect if a player has made damage to another player
 
^um... What's wrong with the dmg param provided by the forward?

HamletEagle 11-16-2014 06:00

Re: Detect if a player has made damage to another player
 
@avril-lavigne, your way is not better, since you already hook Take_Damage you can use the dmg param provided by the ham forward, if you need the damage in other places your way may be better, because you don't need to hook TakeDamage().


All times are GMT -4. The time now is 17:37.

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