Quote:
Originally Posted by generalmemer
PHP Code:
#include <sourcemod>
public void OnClientPutInServer(int iClient) { if( GetClientCount(true) >= 4 ) ServerCommand("bot_kick"); }
|
That will execute the command every single time a player joins if there are at least 4 players already. That will also count players that are bots.
Use this code instead:
PHP Code:
#include <sourcemod>
int g_iCount;
public void OnPluginStart()
{
for (int i = 1; i <= MaxClients; i++)
if (IsClientInGame(i) && !IsFakeClient(i))
g_iCount++;
if (g_iCount >= 4)
ServerCommand("bot_kick");
}
public void OnClientPostAdminCheck(int client)
{
if (!IsFakeClient(client))
g_iCount++;
if (g_iCount == 4)
ServerCommand("bot_kick");
}
public void OnClientDisconnect(int client)
{
if (!IsFakeClient(client))
g_iCount--;
}