I'm trying to create a script which increases the Airstrike's clip when a player scores a direct hit with it. However, I'm running into an issue where the "attacker" client index always returns 0. The "victim" client index returns the correct value. I'm guessing perhaps the event is reporting the rocket and/or the world as the attacker instead of the player? If anyone knows if this is fixable or maybe a workaround I would be very appreciative.
PHP Code:
public void OnPluginStart()
{
HookEvent("projectile_direct_hit", Direct_Hit);
}
public Action Direct_Hit(Event event, const char[] name, bool dontBroadcast)
{
int attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
int victim = GetClientOfUserId(GetEventInt(event, "victim"));
int iWeapon = GetEventInt(event, "weapon_def_index");
if (attacker <= 0 || attacker > MaxClients || !IsValidEntity(iWeapon))
{
PrintToChatAll("Something done fucked up you aint valid son, heres yo client index dawg %i", attacker);
return Plugin_Continue;
}
PrintToChatAll("We made it past the validity check so what now son?");
if (TF2_GetPlayerClass(attacker) == TFClass_Soldier && iWeapon == 1104 && attacker != victim)
{
SetEntProp(attacker, Prop_Send, "m_iDecapitations", GetEntProp(attacker, Prop_Send, "m_iDecapitations") + 1);
TF2_AddCondition(attacker, TFCond_SpeedBuffAlly, 0.01);
PrintToChatAll("You did it right congrats son");
}
return Plugin_Continue;
}