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 == 0 || attacker == victim) // attacker else than player || attacker is victim
{
return; // Don't continue callback
}
new String:weapon[30];
GetEventString(event, "weapon", weapon, sizeof(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.