View Single Post
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 08-14-2019 , 09:57   Re: [TF2] Client is not in game bug
Reply With Quote #17

PHP Code:
public void OnPlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int iClient GetClientOfUserIdevent.GetInt"userid" ) );
    if ( !
iClient // if client is not connected
        
return;

    
// we have a connected client (if he's in game or not, we don't know)
    
if ( GetClientTeamiClient ) == TEAM_BLUE && iClient != g_iLastDeath ) {
        
ChangeAliveClientTeamiClientTEAM_RED );
        
CreateTimer0.2RespawnRebalancedGetClientUserIdiClient ) ); // GetClientUserId returns the userid of a connected client, it doesn't need to be in game
    
}

PHP Code:

public Action RespawnRebalanced(Handle timerany data) {
    
int iClient GetClientOfUserIddata );
    if ( 
iClient && !IsPlayerAliveiClient ) ) // if the client is connected, we don't know if he's in game
        
TF2_RespawnPlayeriClient );

GetClientOfUserId - a connected client from an userid
GetClientUserId - an userid from a connected client

those functions doesn't care if the client is in game or not

you check if the client is in game only in that iteration (code part 2).
maybe the client disconnected and he's still connected but not in game.

the solution for your problem:
PHP Code:

public Action RespawnRebalanced(Handle timerany data) {
    
int iClient GetClientOfUserIddata );
    if ( 
iClient && IsClientInGame(iClient) && !IsPlayerAliveiClient ) )
        
TF2_RespawnPlayeriClient );

__________________

Last edited by Ilusion9; 08-14-2019 at 09:59.
Ilusion9 is offline