TeamManager: ClientInGame --> PostAdminCheck

This commit is contained in:
Dogan 2019-08-14 14:41:59 +02:00
parent f33a9308d0
commit c7333e6e3c

View File

@ -17,12 +17,14 @@ bool g_bRoundEnded = false;
bool g_bZombieSpawned = false; bool g_bZombieSpawned = false;
int g_TeamChangeQueue[MAXPLAYERS + 1] = { -1, ... }; int g_TeamChangeQueue[MAXPLAYERS + 1] = { -1, ... };
int g_iClientsInGame;
public Plugin myinfo = public Plugin myinfo =
{ {
name = "TeamManager", name = "TeamManager",
author = "BotoX", author = "BotoX + Dogan",
description = "", description = "",
version = "1.0", version = "2.0",
url = "https://github.com/CSSZombieEscape/sm-plugins/tree/master/TeamManager" url = "https://github.com/CSSZombieEscape/sm-plugins/tree/master/TeamManager"
}; };
@ -46,6 +48,7 @@ public void OnMapStart()
{ {
g_iWarmup = 0; g_iWarmup = 0;
g_iMaxWarmup = 0; g_iMaxWarmup = 0;
g_iClientsInGame = 0;
g_bWarmup = false; g_bWarmup = false;
g_bRoundEnded = false; g_bRoundEnded = false;
g_bZombieSpawned = false; g_bZombieSpawned = false;
@ -78,14 +81,13 @@ public Action OnWarmupTimer(Handle timer)
if(g_CVar_sm_warmupratio.FloatValue > 0.0) if(g_CVar_sm_warmupratio.FloatValue > 0.0)
{ {
int ClientsConnected = GetClientCount(false); int ClientsConnected = GetClientCount(false);
int ClientsInGame = GetClientCount(true);
int ClientsNeeded = RoundToCeil(float(ClientsConnected) * g_CVar_sm_warmupratio.FloatValue); int ClientsNeeded = RoundToCeil(float(ClientsConnected) * g_CVar_sm_warmupratio.FloatValue);
ClientsNeeded = ClientsNeeded > MIN_PLAYERS ? ClientsNeeded : MIN_PLAYERS; ClientsNeeded = ClientsNeeded > MIN_PLAYERS ? ClientsNeeded : MIN_PLAYERS;
if(ClientsInGame < ClientsNeeded) if(g_iClientsInGame < ClientsNeeded)
{ {
g_iMaxWarmup++; g_iMaxWarmup++;
PrintCenterTextAll("Warmup: Waiting for %d more players to join or %d seconds.", ClientsNeeded - ClientsInGame, g_CVar_sm_warmupmaxtime.IntValue - g_iMaxWarmup); PrintCenterTextAll("Warmup: Waiting for %d more players to join or %d seconds.", ClientsNeeded - g_iClientsInGame, g_CVar_sm_warmupmaxtime.IntValue - g_iMaxWarmup);
return Plugin_Continue; return Plugin_Continue;
} }
else else
@ -104,6 +106,14 @@ public void OnClientDisconnect(int client)
g_TeamChangeQueue[client] = -1; g_TeamChangeQueue[client] = -1;
} }
public void OnClientPostAdminCheck(int client)
{
if(IsFakeClient(client) || IsClientSourceTV(client) || !g_bWarmup)
return;
else
g_iClientsInGame++;
}
public Action OnJoinTeamCommand(int client, const char[] command, int argc) public Action OnJoinTeamCommand(int client, const char[] command, int argc)
{ {
if(client < 1 || client >= MaxClients || !IsClientInGame(client)) if(client < 1 || client >= MaxClients || !IsClientInGame(client))