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_Fire, EventHookMode_PostNoCopy);
#endif
}
void CheckStatus()
{
for(int i =1; i<=MaxClients; i++)
{
// 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(i, name, sizeof(name) );
int health = GetEntProp(i, Prop_Send, "m_iHealth");
float buffer = GetTempHealth(i);
//GetEntPropFloat(i, Prop_Send, "m_healthBuffer");
int count = GetEntProp(i, Prop_Send, "m_currentReviveCount");
PrintToChatAll("%s#HP:%d, TEMP:%f, REV:%d,", name, health, buffer, count);
PrintToServer("%s#HP:%d, TEMP:%f, REV:%d,", name, health, buffer, count);
}
}
}
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.......
__________________