Raised This Month: $51 Target: $400
 12% 

[HELP] Killed by X


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Inject
Junior Member
Join Date: Sep 2013
Old 09-17-2013 , 12:25   [HELP] Killed by X
Reply With Quote #1

How I can find the person who killed someone?
How I can do this?
Inject is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-17-2013 , 13:02   Re: [HELP] Killed by X
Reply With Quote #2

Hook the player_death event and check its userid and attacker fields.

So, something like this:

PHP Code:
public OnPluginStart()
{
    
HookEvent("player_death"Event_PlayerDeath);
}

public 
Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    new 
attacker GetClientOfUserId(GetEventInt(event"attacker"));
    
// if client is 0, the thing killed was a non-player AI.
    // If attacker is 0, the killer is either the world (fall damage, etc...) or a non-player AI
    
if (client || attacker 1)
        return;
        
    
// client is the victim's client index, attacker is the killer's index

Depending on the game, player_death may have additional fields.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 09-17-2013 at 13:12.
Powerlord 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 21:30.


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