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

Solved [TF2] Client is not in game bug


Post New Thread Reply   
 
Thread Tools Display Modes
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 08-14-2019 , 04:10   Re: [TF2] Client is not in game bug
Reply With Quote #11

I mean, look at the code parts at 1st post. I have IsClientInGame checks, so GetClientOfUserId should return 0 only if client is not in game anymore, but client indexes are higher than 0.

I just don't want to waste CPU with these extra checks.
__________________

Last edited by MAGNAT2645; 08-14-2019 at 04:15.
MAGNAT2645 is offline
Whai
Senior Member
Join Date: Jul 2018
Old 08-14-2019 , 04:20   Re: [TF2] Client is not in game bug
Reply With Quote #12

Yes I know it checks only when the player is not in-game anymore on the timer’s code block but I don’t know what I can do except adding IsClientInGame again
__________________
Whai is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 08-14-2019 , 06:15   Re: [TF2] Client is not in game bug
Reply With Quote #13

Maybe the client is connected but not in game. Just check if the client is in game in that callback.
__________________
Ilusion9 is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 08-14-2019 , 08:17   Re: [TF2] Client is not in game bug
Reply With Quote #14

RespawnRebalanced won't be called if client is not in game (see code from 1st post), GetClientOfUserId returns index higher than 0, that means client still playing but then reports that client is not in game (in this case GetClientOfUserId should return 0, but this does not happen)
__________________
MAGNAT2645 is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 08-14-2019 , 09:04   Re: [TF2] Client is not in game bug
Reply With Quote #15

Quote:
Originally Posted by MAGNAT2645 View Post
RespawnRebalanced won't be called if client is not in game (see code from 1st post), GetClientOfUserId returns index higher than 0, that means client still playing but then reports that client is not in game (in this case GetClientOfUserId should return 0, but this does not happen)
GetClientOfUserId returns a connected client. Clients can have userids before being in game.
__________________
Ilusion9 is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 08-14-2019 , 09:39   Re: [TF2] Client is not in game bug
Reply With Quote #16

I know, but this callback won't be called if client is not in game (i think you just haven't seen the bold (now it's green) text from 1st post)
__________________

Last edited by MAGNAT2645; 08-14-2019 at 09:41.
MAGNAT2645 is offline
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
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 08-14-2019 , 10:14   Re: [TF2] Client is not in game bug
Reply With Quote #18

I know all about these functions because i'm using them a lot (without any errors, but this situation is an exception)

I'm sure, OnPlayerSpawn is not called on connecting (not in game) players, so if (!iClient) check just to ensure that we're working with real player.

Quote:
you check if the client is in game only in that iteration (code part 2).
Client can't be in game if he's not connected.

Quote:
maybe the client disconnected and he's still connected but not in game.
Client can't be disconnected and connected at same time.

I put userids of clients that in-game and if GetClientOfUserid returns 0 inside callback that means that *this* userid disconnected before callback execution.

Quote:
the solution for your problem:
I've already posted this solution, but i think it's just a waste of CPU.
__________________

Last edited by MAGNAT2645; 08-14-2019 at 10:21. Reason: Additional info
MAGNAT2645 is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 08-14-2019 , 10:34   Re: [TF2] Client is not in game bug
Reply With Quote #19

player_spawn event is called as well when the player spawns into the game

Quote:
Originally Posted by MAGNAT2645 View Post
Client can't be in game if he's not connected.
yes, but i've said you check if the player is in game only in that loop and not in player_spawn event.

Quote:
Originally Posted by MAGNAT2645 View Post
if (!iClient) check just to ensure that we're working with real player.
that player is just connected (IsClientConnected returns true), but that player can not be in game (IsClientInGame can return false).

You should see which part of your code gives errors (player_spawn or that loop). I'm 100% sure that is the player_spawn event.
__________________

Last edited by Ilusion9; 08-14-2019 at 10:35.
Ilusion9 is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 08-14-2019 , 10:40   Re: [TF2] Client is not in game bug
Reply With Quote #20

I dont have this error on my plugins (i use player_spawn event a lot) which uses the same client check method so i don't know if this is a bug.
__________________

Last edited by MAGNAT2645; 08-14-2019 at 10:48. Reason: mistake fixed
MAGNAT2645 is offline
Reply


Thread Tools
Display Modes

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 08:15.


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