Raised This Month: $81 Target: $400
 20% 

[L4D2] About "IsClientInGame()"


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Iciaria
Member
Join Date: Aug 2022
Old 03-25-2023 , 09:27   [L4D2] About "IsClientInGame()"
Reply With Quote #1

I'm having some problems writing a plugin.
The code snippet looks like this

PHP Code:
public void OnPluginStart()
{
#if DEBUG
        
HookEvent("weapon_fire"Event_Weapon_FireEventHookMode_PostNoCopy);            
#endif
}

void CheckStatus()
{
        for(
int i =1i<=MaxClientsi++)
        {
//              if(!IS_VALID_SURVIVOR(i))
//              if(!IsValidEntity(i) )
//                      return;
//              PrintToChatAll("1");
//              if(!IsClientConnected(i) )
//                      return;
//              PrintToChatAll("2");
//              if(!IsValiClient(i) )
//                      return;
                
if(!IsClientInGame(i) )
                        return;
                if(
GetClientTeam(i) == 2)
                {       
                        
char name[64];
                        
GetClientName(inamesizeof(name) );
                        
int health GetEntProp(iProp_Send"m_iHealth");
                        
float buffer GetTempHealth(i);
//GetEntPropFloat(i, Prop_Send, "m_healthBuffer");
                        
int count GetEntProp(iProp_Send"m_currentReviveCount");
                        
PrintToChatAll("%s#HP:%d, TEMP:%f, REV:%d,"namehealthbuffercount);
                        
PrintToServer("%s#HP:%d, TEMP:%f, REV:%d,"namehealthbuffercount);
                }
        }


I run many tests on my multiple servers.
"IsClientInGame()" sometimes thinks the client is not in the game.

The following situations have occurred in the test:
Code:
1.Only the first player to join is considered "in game".
2.Following the first point, when a second player joins the server, the fake client will be considered "Not in game", and . The second player is also sometimes considered "Not in game".
3.All players, fake clients or not, are correctly considered "in game"
4.Only real players are considered "in game"
I also tested in pure server and the result is still the same
Initially, it throws
Code:
 03/24/2023 - 19:59:23: [SM] Call stack trace:
L 03/24/2023 - 19:59:23: [SM]   [0] Event.GetInt
L 03/24/2023 - 19:59:23: [SM]   [1] Line 90, test.sp::Event_Weapon_Fire
After I removed "EventHookMode_PostNoCopy", the error in the log above disappeared. However, the problem is still happening..

I also tried changing the cvars "sv_lan" and "sv_cheats", but, the miracle didn't happen.

Can anyone tell me what exactly is going on?
I'm very confused.......
__________________
Sorry,my english not good
Iciaria is offline
 


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 14:35.


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