fixed a bug where setting cssdm_bots_balance to 0 would cause bot_quota to stop working
3 * Adds bot quota correction to CS:S DM.
4 * This file is part of CS:S DM, Copyright (C) 2005-2007 AlliedModders LLC
5 * by David "BAILOPAN" Anderson, http://www.bailopan.net/cssdm/
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 public Plugin:myinfo =
30 name = "CS:S DM Bot Quotas",
32 description = "Bot Quota Correction for CS:S DM",
33 version = CSSDM_VERSION,
34 url = "http://www.bailopan.net/cssdm/"
38 new Handle:BotQuota = INVALID_HANDLE
41 new Handle:BalanceAmt = INVALID_HANDLE
43 public OnPluginStart()
45 /* Find CS:S ConVars */
46 BotQuota = FindConVar("bot_quota")
48 /* Create our ConVars */
49 BalanceAmt = CreateConVar("cssdm_bots_balance", "0", "Minimum number of players (bot_quota)")
50 HookConVarChange(BalanceAmt, OnBalanceChange)
55 BalanceBots(GetConVarInt(BalanceAmt));
58 public OnBalanceChange(Handle:convar, const String:oldval[], const String:newval[])
60 BalanceBots(StringToInt(newval))
70 new maxClients = GetMaxClients()
73 /* Get the number of valid humans and bots */
74 for (new i=1; i<=maxClients; i++)
76 if (!IsClientInGame(i))
88 /* Get the number of bots needed to fill quota */
96 /* Now, set the new value */
97 SetConVarInt(BotQuota, quota)
100 public OnClientPutInServer(client)
102 BalanceBots(GetConVarInt(BalanceAmt))
105 public OnClientDisconnect_Post(client)
107 BalanceBots(GetConVarInt(BalanceAmt))