#include <sourcemod>

#define PLUGIN_VERSION "1.0.0"

public Plugin:myinfo = 
{
	name = "Bot Quota Kick",
	author = "MadMakz",
	description = "Destroy Bots not respecting the Quota",
	version = PLUGIN_VERSION,
	url = "http://cgx24.com"
};

new Handle:cBotQuota;
new sBotQuota;

public OnPluginStart()
{
	CreateConVar("bqk_version", PLUGIN_VERSION, "Destroy Bots not respecting the Quota", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
	cBotQuota = FindConVar("bot_quota");
	
	
}

public OnClientPostAdminCheck()
{	
	if (cBotQuota != INVALID_HANDLE)
	{
		sBotQuota = GetConVarInt(cBotQuota);
		if (GetRealClientCount() >= sBotQuota)
		{
			ServerCommand("bot_kick");
		}
	}
}

stock GetRealClientCount(bool:inGameOnly = true)
{
	new clients = 0;
	for(new i = 1; i <= GetMaxClients(); i++)
	{
		if (((inGameOnly) ? IsClientInGame(i) : IsClientConnected(i)) && !IsFakeClient(i))
		{
			clients++;
		}
	}
	return clients;
}