I am trying to work on a previous plugin that was posted by Vato Loco. The plugin sets a set number of active bots and then reduces the bot_quota when a player joins until the max number of bots reaches zero. However when there are no players in the server the bot quota also is set to zero. How could I change this so when there is also zero players in the server that the bots would not leave! Thanks!!
PHP Code:
/* AMX Mod Plugin
*
* (c) Copyright 2007, DokTor
* This file is provided as is (no warranties).
*
*/
#include <amxmod>
new max_bots, bot_quota
public plugin_init() {
register_plugin("cz bots","0.1","DokTor")
max_bots = register_cvar("amx_max_bot","10")
bot_quota = get_cvar_pointer("bot_quota")
}
public plugin_cfg() {
set_task(5.0, "check_players", 7896541, _, _, "b")
}
public check_players() {
new players[32], inum, num
get_players(players, num, "c")
for(new i; i<num; ++i)
{
new team = get_user_team(players[i])
if(team == 1 || team == 2)
++inum
}
new max = get_pcvar_num(max_bots)
if(inum <= max)
set_pcvar_num(bot_quota,max - inum)
else if(inum > max)
{
set_pcvar_num(bot_quota,0)
new joueurs[32], bnum
get_players(joueurs, bnum, "d")
for(new i; i<bnum; ++i)
{
if(is_user_bot(joueurs[i]))
{
new userid = get_user_userid(joueurs[i])
server_cmd("kick #%d", userid)
}
}
return
}
check_balance()
}
check_balance() {
new ct[32], terro[32], ctnum, tnum
get_players(terro, tnum, "e", "1")
get_players(ct, ctnum, "e", "2")
if(ctnum - tnum > 1)
{
for(new i; i<ctnum; ++i)
{
if(is_user_bot(ct[i]))
{
server_cmd("kick #%d", get_user_userid(ct[i]))
break
}
}
}
else if(tnum - ctnum > 1)
{
for(new i; i<tnum; ++i)
{
if(is_user_bot(terro[i]))
{
server_cmd("kick #%d", get_user_userid(terro[i]))
break
}
}
}
}