Raised This Month: $ Target: $400
 0% 

Detect if a player has made damage to another player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hackerpcs
Member
Join Date: Jul 2012
Location: Greece
Old 11-15-2014 , 17:29   Detect if a player has made damage to another player
Reply With Quote #1

As title says, how do I do it?
Hackerpcs is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 11-15-2014 , 17:36   Re: Detect if a player has made damage to another player
Reply With Quote #2

Hook Ham_TakeDamage
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Hackerpcs
Member
Join Date: Jul 2012
Location: Greece
Old 11-15-2014 , 18:15   Re: Detect if a player has made damage to another player
Reply With Quote #3

Quote:
Originally Posted by YamiKaitou View Post
Hook Ham_TakeDamage
Some more details? I'm not experienced with Hamsandwich.
Hackerpcs is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 11-15-2014 , 18:20   Re: Detect if a player has made damage to another player
Reply With Quote #4

Search
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).

Last edited by YamiKaitou; 11-15-2014 at 18:21.
YamiKaitou is offline
Hackerpcs
Member
Join Date: Jul 2012
Location: Greece
Old 11-15-2014 , 18:46   Re: Detect if a player has made damage to another player
Reply With Quote #5

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?
Hackerpcs is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-15-2014 , 19:13   Re: Detect if a player has made damage to another player
Reply With Quote #6

Quote:
Originally Posted by Hackerpcs View Post
Is this correct?
Did you test it?
__________________
fysiks is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 11-15-2014 , 20:13   Re: Detect if a player has made damage to another player
Reply With Quote #7

Just learn from this code: https://forums.alliedmods.net/showthread.php?t=88577
zmd94 is offline
avril-lavigne
Banned
Join Date: Apr 2009
Old 11-16-2014 , 02:21   Re: Detect if a player has made damage to another player
Reply With Quote #8

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) ) 
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc
avril-lavigne is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 11-16-2014 , 05:54   Re: Detect if a player has made damage to another player
Reply With Quote #9

^um... What's wrong with the dmg param provided by the forward?
RateX is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-16-2014 , 06:00   Re: Detect if a player has made damage to another player
Reply With Quote #10

@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().
__________________
HamletEagle 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 20:08.


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