Raised This Month: $32 Target: $400
 8% 

[TF2] "[SM] Exception reported: Client index 96 is invalid"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 08-22-2017 , 01:36   [TF2] "[SM] Exception reported: Client index 96 is invalid"
Reply With Quote #1

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!!
ThatKidWhoGames is offline
stephen473
Senior Member
Join Date: Jan 2017
Location: somewhere on earth
Old 08-22-2017 , 07:46   Re: [TF2] "[SM] Exception reported: Client index 96 is invalid"
Reply With Quote #2

change IsClientInGame to IsValidClient, it'll fix your problem.

PHP Code:
stock bool IsValidClient(int clientbool bAllowBots falsebool bAllowDead true)
{
    if (!(
<= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !bAllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!bAllowDead && !IsPlayerAlive(client)))
    {
        return 
false;
    }
    return 
true;

__________________
Also known as Hardy`.

Feel free to contact me if you have a private plugin request!

My Steam Profile | Discord: Hardy`#3792
stephen473 is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 08-22-2017 , 12:19   Re: [TF2] "[SM] Exception reported: Client index 96 is invalid"
Reply With Quote #3

Quote:
Originally Posted by stephen473 View Post
change IsClientInGame to IsValidClient, it'll fix your problem.

PHP Code:
stock bool IsValidClient(int clientbool bAllowBots falsebool bAllowDead true)
{
    if (!(
<= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !bAllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!bAllowDead && !IsPlayerAlive(client)))
    {
        return 
false;
    }
    return 
true;

Thanks man, that did the trick!!

Last edited by ThatKidWhoGames; 08-22-2017 at 13:30.
ThatKidWhoGames 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 01:14.


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