Raised This Month: $ Target: $400
 0% 

Displaying call stack trace for plugin


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-23-2012 , 10:21   Re: Displaying call stack trace for plugin
Reply With Quote #7

When use "player_hurt" event, "attacker" can return with invalid userid == 0,
happens when player hurt by fire, fall damage or get hurt something else than other player(s).

When try get client index by given userid,
GetClientOfUserId(userid) will return 0 if not found. 0 is invalid client index.

Valid client index is between 1 and your server maxplayers.

It is important to look first client index before continue check rest player things.

PHP Code:
public OnPluginStart()
{
    
HookEventEx("player_hurt"player_hurt);
}

public 
player_hurt(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
attacker GetClientOfUserId(GetEventInt(event"attacker"));
    new 
victim GetClientOfUserId(GetEventInt(event"userid"));

    if(
attacker == || attacker == victim// attacker else than player || attacker is victim
    
{
        return; 
// Don't continue callback
    
}

    new 
String:weapon[30];
    
GetEventString(event"weapon"weaponsizeof(weapon));

    if( !
StrEqual(weapon"jockey_claw") ) // weapon not "jockey_claw"
    
{
        return;
    }

    
// Add here your your rest code
    // attacker is jockey if weapon "jockey_claw", not need check team. If jockey not have more weapons.
    // victim should be survivor, I assume now those Special Infected can't hurt each other, I could be wrong.



sry bad english.

Last edited by Bacardi; 10-23-2012 at 10:22.
Bacardi is offline
 



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 11:43.


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