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 );
}
__________________