View Single Post
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 09-18-2018 , 11:50   Re: Need easy pluing to exec bot_kick when 4 players in server
Reply With Quote #3

Quote:
Originally Posted by generalmemer View Post
PHP Code:
#include <sourcemod> 

public void OnClientPutInServer(int iClient)
{
    if( 
GetClientCount(true) >= )
        
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<= MaxClientsi++)
        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--;


Last edited by ThatKidWhoGames; 09-18-2018 at 11:56.
ThatKidWhoGames is offline