Raised This Month: $202 Target: $400
 50% 

count dmg


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CHyCMyMpNk
Senior Member
Join Date: Jun 2008
Location: PTZ
Old 10-01-2012 , 09:37   count dmg
Reply With Quote #1

hello world)
How to count how many players inflict damage to another player?

Last edited by CHyCMyMpNk; 10-01-2012 at 09:37.
CHyCMyMpNk is offline
Send a message via ICQ to CHyCMyMpNk
fl0werD
Senior Member
Join Date: May 2011
Old 10-01-2012 , 10:37   Re: count dmg
Reply With Quote #2

Quote:
Originally Posted by chycmympnk View Post
hello world)
how to count how many players inflict damage to another player?
Едрить ты бестолочь. Занести урон в переменную в ТэйкДэмэйдж.
fl0werD is offline
Send a message via ICQ to fl0werD
Bos93
Veteran Member
Join Date: Jul 2010
Old 10-01-2012 , 10:52   Re: count dmg
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod
Hey nive NOSTEAM server in your sig !
__________________

Last edited by Bos93; 10-01-2012 at 10:53.
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 10-01-2012 , 11:06   Re: count dmg
Reply With Quote #4

this is a very simple problem to solve. What do you think you'll need?

I'll start you off with an event hook.

Code:
register_event("Damage", "fwd_event_damage", "2!0")
and a link.
http://wiki.amxmodx.org/Half-Life_1_Game_Events#Damage

Start thinking and i'll start helping. This should get you started.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
CHyCMyMpNk
Senior Member
Join Date: Jun 2008
Location: PTZ
Old 10-01-2012 , 11:09   Re: count dmg
Reply With Quote #5

new count

if (is_user_alive(attacker) && is_user_alive(victim))
{
count++
}

I don `t know how best to do it ...
CHyCMyMpNk is offline
Send a message via ICQ to CHyCMyMpNk
Bos93
Veteran Member
Join Date: Jul 2010
Old 10-01-2012 , 11:18   Re: count dmg
Reply With Quote #6

try this:
PHP Code:
#include < amxmodx >
#include < hamsandwich >

const MAX_CLIENTS 32;

new 
g_pevVictimCountMAX_CLIENTS ];

public 
plugin_init()
{
    
RegisterHamHam_TakeDamage"player",     "CBasePlayer__TakeDamage_Post", .Post true );
}

public 
CBasePlayer__TakeDamage_PrepevVictimpevInflictorpevAttackerFloat:flDamageiDmgBits )
{
    if ( !
is_user_alivepevAttacker ) )
    {
        return 
HAM_HANDLED;
    }

    
g_pevVictimCountpevVictim ]++;

    return 
HAM_IGNORED;

__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
CHyCMyMpNk
Senior Member
Join Date: Jun 2008
Location: PTZ
Old 10-01-2012 , 11:26   Re: count dmg
Reply With Quote #7

[en]
Don't know how to explain in English)
use http://translate.google.ru/
The bottom line is you have to count the number of attackers at the time of damage to the victim. For example take one zombie player. How to count how many people are here on it shoots + given the fact that someone might not shoot as recharged or even shoot and run away at all)

[ru]
Суть в том что нужно считать кол-во атакующих во время получения урона по жертве. Например взять 1 зомби игрока. Как вот сосчитать сколько народу по нему стреляет, + учесть то что кто то может вообще не стрелять т.к. перезаряжается или вообще пострелял и убежал напрочь )
CHyCMyMpNk is offline
Send a message via ICQ to CHyCMyMpNk
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 10-01-2012 , 12:19   Re: count dmg
Reply With Quote #8

If you're looking to see WHO inflicts damage, and not how much damge was done. I'd have an array of bitsums. You'll have something that looks like this.

Code:
new g_victimAttackers[33]
#define attacked(%1,%2)    g_victimAttackers[%1] |= (1 << (%2 & 31))
#define clear(%1)               g_victimAttackers[%1] = 0
This variable and macros will allow you to set the player who attacked whoever. calling as such...attacked(victim, attacker) Then clear clears the bitsum.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 10-01-2012 , 13:44   Re: count dmg
Reply With Quote #9

I think he wants how many players inflicts damage on each player.
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 10-02-2012 , 10:02   Re: count dmg
Reply With Quote #10

Quote:
Originally Posted by Neeeeeeeeeel.- View Post
I think he wants how many players inflicts damage on each player.
Yes, that's what my solution entails. Any other way you're going to need to check to see if that player already attacked him. This way you aren't using a 33x33 matrix (saving memory) and you have the speed of a bitsum and only one array index. Hardest thing you'll have to do is counting the bits. But that's as simple as this....

PHP Code:
new attackersCount
new players[32], plrcnt
get_players
(playersplrcnt"ch")

for(new 
0plrcnti++)
{
    if(
g_victimAttackers[id] & (<< (players[i] & 31)) )
        
attackersCount++

EDIT: unless one of the smart people on here knows a faster way to calculate the bits in a number....
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 10-02-2012 at 10:41.
Liverwiz is offline
Reply


Thread Tools
Display Modes

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 03:21.


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