Raised This Month: $ Target: $400
 0% 

How to check if player has killed somebody


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dreamedward
Senior Member
Join Date: Aug 2010
Location: ZombieWorld
Old 09-09-2011 , 16:02   How to check if player has killed somebody
Reply With Quote #1

So I was wondering how can I check does a specific player killed somebody in the round. I mean in round one Player from the CTs has killed 1, 2, 3... etc Ts(there is FriendlyFire On so i want only kills to the opposite team to be checked) and if he has killed somebody(without teammates) to do a function. But lets guess that in round two he hasn't killed nobody. Well he hasn't killed nobody so I don't want any function to be done. I hope you've understood me right. I'll be waiting for responces
dreamedward is offline
Desikac
Senior Member
Join Date: Apr 2010
Location: Serbia
Old 09-09-2011 , 17:07   Re: How to check if player has killed somebody
Reply With Quote #2

PHP Code:
#include <amxmodx>
#include <cstrike>

new KillCount[33]

public 
plugin_init() {
    
register_messageget_user_msgid"DeathMsg" ) , "death" )
    
register_logevent("ResetKills",2,"1=Round_Start")
}

public 
client_disconnect(id)
    
KillCount[id] = 0

    
public ResetKills(){
    new 
players[32] , inum
    get_players
(playersinum)
    for(new 
0inum; ++a)
        
KillCount[a] = 0
}
public 
death() {
    new 
attacker read_data(1);
    new 
victim read_data(2);
       
    if(
attacker == victim)
        return 
PLUGIN_CONTINUE
    
    
if(cs_get_user_team(attacker) == cs_get_user_team(victim))
        return 
PLUGIN_CONTINUE
    
    KillCount
[attacker]++
    
    if(
KillCount[attacker] == 3) {
        
//if he has killed 3 this round execute a function
        
SomeFunction(attacker)
    }
    
    return 
PLUGIN_CONTINUE
    
}

public 
SomeFunction(id) {
    
//your code here
    
client_print(idprint_chat"This is your third kill this round!")

Desikac is offline
Send a message via MSN to Desikac Send a message via Skype™ to Desikac
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 09-09-2011 , 17:30   Re: How to check if player has killed somebody
Reply With Quote #3

Just another way

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>

#define m_LastHitGroup 75
new KillCount[33]

public 
plugin_init()
{
    
RegisterHam(Ham_Killed"player""death");
    
register_logevent("ResetKills",2,"1=Round_Start")
}

public 
client_disconnect(id)
    
KillCount[id] = 0

    
public ResetKills()
{
    new 
players[32] , inum
    get_players
(playersinum)
    for(new 
0inum; ++a)
        
KillCount[a] = 0
}
public 
death(iVictimiInflictoriAttackeriShouldGib)
{
    new 
HitGroup get_pdata_int(iVictimm_LastHitGroup);
    if(
iAttacker != iVictim && cs_get_user_team(iVictim) != cs_get_user_team(iAttacker))
    {
        
KillCount[iAttacker]++
        
        if(
HitGroup == HIT_HEAD)
        {
            
//Was a Headshot
        
}
    
        if(
KillCount[iAttacker] == 3)
        {
            
//if he has killed 3 this round execute a function
            
SomeFunction(iAttacker)
        }
    }
    
    return 
HAM_IGNORED;
}

public 
SomeFunction(id)
{
    
//your code here
    
client_print(idprint_chat"This is your third kill this round!")

you can check head shots also in death message by using read_data(3) and doing a check like this

PHP Code:
new HeadShot read_data(3)

if(
HeadShot)
{
    
//Was a headshot

Also i didnt edit his code just changed it over to ham so i didn't test the way it works.
Doc-Holiday is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-10-2011 , 04:12   Re: How to check if player has killed somebody
Reply With Quote #4

Quote:
Originally Posted by Desikac View Post
PHP Code:
#include <amxmodx>
#include <cstrike>

new KillCount[33]

public 
plugin_init() {
    
register_messageget_user_msgid"DeathMsg" ) , "death" )
    
register_logevent("ResetKills",2,"1=Round_Start")
}

public 
client_disconnect(id)
    
KillCount[id] = 0

    
public ResetKills(){
    new 
players[32] , inum
    get_players
(playersinum)
    for(new 
0inum; ++a)
        
KillCount[a] = 0
}
public 
death() {
    new 
attacker read_data(1);
    new 
victim read_data(2);
       
    if(
attacker == victim)
        return 
PLUGIN_CONTINUE
    
    
if(cs_get_user_team(attacker) == cs_get_user_team(victim))
        return 
PLUGIN_CONTINUE
    
    KillCount
[attacker]++
    
    if(
KillCount[attacker] == 3) {
        
//if he has killed 3 this round execute a function
        
SomeFunction(attacker)
    }
    
    return 
PLUGIN_CONTINUE
    
}

public 
SomeFunction(id) {
    
//your code here
    
client_print(idprint_chat"This is your third kill this round!")

Check if attacker is connected.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Coincidence
Junior Member
Join Date: Jun 2011
Old 09-11-2011 , 11:40   Re: How to check if player has killed somebody
Reply With Quote #5

can be attacker not connected ?
Coincidence is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-11-2011 , 12:54   Re: How to check if player has killed somebody
Reply With Quote #6

Quote:
Originally Posted by Coincidence View Post
can be attacker not connected ?
Yes.
__________________
fysiks is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 09-11-2011 , 16:07   Re: How to check if player has killed somebody
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
Yes.
How???
After all, this is not possible
.Dare Devil. is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-11-2011 , 16:22   Re: How to check if player has killed somebody
Reply With Quote #8

Because it's how gt_user_attacker is done, it checks inflictor, if inflictor is a player it returns the player index, if it's a nade it returns the owner of that nade, if it's another entity type, it returns the owner of that entity if it is a player, else the entity itself.

http://www.amxmodx.org/funcwiki.php?...cker&go=search

Quote:
As of 1.75, get_user_attacker can return a non-player index if the player was attacked by a non-player entity.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 09-11-2011 , 23:24   Re: How to check if player has killed somebody
Reply With Quote #9

Also it can be worldspawn (0) if for example you die by falling.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 09-12-2011 , 16:32   Re: How to check if player has killed somebody
Reply With Quote #10

at least check if the player is alive then.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
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 09:11.


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