Hey all,
So I have coded a plugin that is basically meant for tracking player's deaths and determining who killed them. I am providing a snippet of this plugin.
Code:
HookEvents()
{
HookEvent("player_death", Event_PlayerDeath);
}
public void Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
if (IsClientInGame(attacker) && GetClientTeam(attacker) == 2 && TF2Jail_IsWarden(victim))
{
new String:steamid[32];
GetClientAuthId(attacker, AuthId_Steam2, steamid, sizeof(steamid));
decl String:sQuery[256];
Format(sQuery, sizeof(sQuery), "UPDATE `rebelstats` SET `warden_kills` = `warden_kills` + 1 WHERE `steamid` = '%s';", steamid);
SQL_TQuery(g_hDatabase, DBPostUpdateGuardKills, sQuery);
}
else if (IsClientInGame(attacker) && GetClientTeam(attacker) == 2 && !TF2Jail_IsWarden(victim) && GetClientTeam(victim) == 3)
{
new String:steamid[32];
GetClientAuthId(attacker, AuthId_Steam2, steamid, sizeof(steamid));
decl String:sQuery[256];
Format(sQuery, sizeof(sQuery), "UPDATE `rebelstats` SET `guard_kills` = `guard_kills` + 1 WHERE `steamid` = '%s';", steamid);
SQL_TQuery(g_hDatabase, DBPostUpdateGuardKills, sQuery);
}
}
I am having an issue though. The database query part isn't the issue but whenever a rebel kill's a guard, I get this:
Code:
L 08/21/2017 - 18:30:31: [SM] Exception reported: Client index 96 is invalid
L 08/21/2017 - 18:30:31: [SM] Blaming: rebelstats.smx
L 08/21/2017 - 18:30:31: [SM] Call stack trace:
L 08/21/2017 - 18:30:31: [SM] [0] IsClientInGame
L 08/21/2017 - 18:30:31: [SM] [1] Line 154, C:\Users\grant\Documents\SourceMod Projects\rebelstats.sp::Event_PlayerDeath
Any help would be greatly appreciated!!