Raised This Month: $51 Target: $400
 12% 

Solved [TF2] Client is not in game bug


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 08-13-2019 , 16:53   [TF2] Client is not in game bug
Reply With Quote #1

SM logs this annoying "is not in game" error but i've put client check via userid.

Code:
L 08/11/2019 - 09:11:29: [SM] Exception reported: Client 3 is not in game
L 08/11/2019 - 09:11:29: [SM] Blaming: disabled/deathrun_redux.smx
L 08/11/2019 - 09:11:29: [SM] Call stack trace:
L 08/11/2019 - 09:11:29: [SM]   [0] IsPlayerAlive
L 08/11/2019 - 09:11:29: [SM]   [1] Line 1666, DeathRun Redux 2019::RespawnRebalanced
Code part #1:
Code:
public void OnPlayerSpawn(Event event, const char[] name, bool dontBroadcast) {
	if ( !g_bIsDRmap )
		return;

	int iClient = GetClientOfUserId( event.GetInt( "userid" ) );
	if ( !iClient )
		return;

	if ( g_bDisableFallDamage )
		TF2Attrib_SetByName( iClient, "cancel falling damage", 1.0 );

	int iCond = GetEntProp( iClient, Prop_Send, "m_nPlayerCond" );
	if ( iCond & PLAYERCOND_SPYCLOAK )
		SetEntProp( iClient, Prop_Send, "m_nPlayerCond", iCond | ~PLAYERCOND_SPYCLOAK );

	if ( GetClientTeam( iClient ) == TEAM_BLUE && iClient != g_iLastDeath ) {
		ChangeAliveClientTeam( iClient, TEAM_RED );
		CreateTimer( 0.2, RespawnRebalanced, GetClientUserId( iClient ) );
	}

	if ( g_bOnPreparation )
		SetEntityMoveType( iClient, MOVETYPE_NONE );
}
Code part #2:
Code:
	g_iLastDeath = iNewDeath;
	int iTeam;
	for ( int i = 1; i <= MaxClients; i++ ) {
		if ( !IsClientInGame( i ) )
			continue;

		iTeam = GetClientTeam( i );
		if ( iTeam < TEAM_RED )
			continue;

		if ( i == iNewDeath ) {
			if ( iTeam != TEAM_BLUE )
				ChangeAliveClientTeam( i, TEAM_BLUE );

			if ( TF2_GetPlayerClass( i ) == TFClass_Unknown )
				TF2_SetPlayerClass( i, TFClass_Scout, false, true );

			g_iQueuePriory[ i ] = 1;
		}
		else if ( iTeam != TEAM_RED )
			ChangeAliveClientTeam( i, TEAM_RED );

		CreateTimer( 0.2, RespawnRebalanced, GetClientUserId( i ) );
	}
RespawnRebalanced code:
Code:
public Action RespawnRebalanced(Handle timer, any data) {
	int iClient = GetClientOfUserId( data );
	if ( iClient && !IsPlayerAlive( iClient ) )
		TF2_RespawnPlayer( iClient );
}
__________________

Last edited by MAGNAT2645; 08-16-2019 at 08:11. Reason: I think, it's solved
MAGNAT2645 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 08-13-2019 , 19:27   Re: [TF2] Client is not in game bug
Reply With Quote #2

Just to be clear, this is the only CreateTimer that uses the RespawnRebalanced callback?
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 08-14-2019 , 03:21   Re: [TF2] Client is not in game bug
Reply With Quote #3

Quote:
Originally Posted by Powerlord View Post
Just to be clear, this is the only CreateTimer that uses the RespawnRebalanced callback?
Yes, i've checked that only these two timers uses RespawnRebalanced.
__________________
MAGNAT2645 is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 08-13-2019 , 19:35   Re: [TF2] Client is not in game bug
Reply With Quote #4

I sometimes get that error. Very rare for me, but after testing I found it to be valid. The cause for me was running code on Bots who were kicked after checking if in game but before code could completely finish executing. A human player would join the game and a bot would be kicked at just the right moment to pop that error. As I said... very rare.
PC Gamer is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 08-14-2019 , 03:24   Re: [TF2] Client is not in game bug
Reply With Quote #5

Quote:
Originally Posted by PC Gamer View Post
I sometimes get that error. Very rare for me, but after testing I found it to be valid. The cause for me was running code on Bots who were kicked after checking if in game but before code could completely finish executing. A human player would join the game and a bot would be kicked at just the right moment to pop that error. As I said... very rare.
This error appears on public server with no bots.
__________________
MAGNAT2645 is offline
Whai
Senior Member
Join Date: Jul 2018
Old 08-14-2019 , 03:45   Re: [TF2] Client is not in game bug
Reply With Quote #6

You have to do that :
PHP Code:
if ( iClient )
   if ( !
IsPlayerAliveiClient ) )
      
TF2_RespawnPlayeriClient ); 
Because your code checks the client index is not equal to 0 BUT also checks at the SAME TIME if the player is alive
__________________

Last edited by Whai; 08-14-2019 at 03:46.
Whai is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 08-15-2019 , 15:42   Re: [TF2] Client is not in game bug
Reply With Quote #7

Quote:
Originally Posted by Whai View Post
You have to do that :
PHP Code:
if ( iClient )
   if ( !
IsPlayerAliveiClient ) )
      
TF2_RespawnPlayeriClient ); 
Because your code checks the client index is not equal to 0 BUT also checks at the SAME TIME if the player is alive
Imagine the pain of developing a program if conditional's boolean checks were asynchronous.
Mitchell is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 08-15-2019 , 22:50   Re: [TF2] Client is not in game bug
Reply With Quote #8

Quote:
Originally Posted by Mitchell View Post
Imagine the pain of developing a program if conditional's boolean checks were asynchronous.
See also: Race conditions in multi-threaded programming.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 08-16-2019 , 18:25   Re: [TF2] Client is not in game bug
Reply With Quote #9

Quote:
Originally Posted by Powerlord View Post
See also: Race conditions in multi-threaded programming.
I think the one off the top of my head from a bug I've introduced is:
System.out.format().println();
(Except System.out was interchangeable output stream)
Essentially the format could happen twice before the next line character would be called and make one long line of unparseable data for splunk and an extra empty line)
Mitchell is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 08-14-2019 , 03:49   Re: [TF2] Client is not in game bug
Reply With Quote #10

But second part (IsPlayerAlive) won't execute if first part (iClient != 0) will return false...
__________________

Last edited by MAGNAT2645; 08-14-2019 at 03:50.
MAGNAT2645 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 15:53.


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