PHP Code:
#pragma semicolon 1
#pragma ctrlchar '\'
new Plugin[11] =
{
90, 80, 54, 50, 83, 112, 101, 99, 116, 115, 0
}
new Version[6] =
{
50, 46, 56, 46, 49, 0
}
new Author[17] =
{
83, 111, 104, 97, 105, 98, 88, 116, 114, 101, 109, 101, 46, 78, 101, 84, 0
}
new bool:is_user_ffbot[33];
new bool:checkingStatus;
new bool:changingBots;
new botCount;
new namesread;
new namesToUse[256][33];
new pDelay;
new pAuto;
new pPlayers;
Float:operator*(Float:,_:)(Float:oper1, oper2)
{
return oper1 * float(oper2);
}
bool:operator<=(Float:,Float:)(Float:oper1, Float:oper2)
{
return 0 >= floatcmp(oper1, oper2);
}
cmd_access(id, level, cid, num, bool:accesssilent)
{
!!! Removed Phi
new has_access = 0;
new var1;
if (is_dedicated_server())
{
var1 = 0;
}
else
{
var1 = 1;
}
if (var1 == id)
{
has_access = 1;
}
else
{
if (level == 16777216)
{
if (is_user_admin(id))
{
has_access = 1;
}
}
if (level & get_user_flags(id, 0))
{
has_access = 1;
}
if (level)
{
}
else
{
has_access = 1;
}
}
if (has_access)
{
if (num > read_argc())
{
new hcmd[32];
new hinfo[128];
new hflag = 0;
get_concmd(cid, hcmd, 31, hflag, hinfo, 127, level, -1);
console_print(id, "%L: %s %s", id, "USAGE", hcmd, hinfo);
return 0;
}
return 1;
}
if (!accesssilent)
{
console_print(id, "%L", id, "NO_ACC_COM");
}
return 0;
}
get_configsdir(String:name[], len)
{
return get_localinfo("amxx_configsdir", name, len);
}
public plugin_init()
{
register_plugin("SpecBots", "2.8.1", "OhMyWay");
pAuto = register_cvar("ff_automode", "0", 0, 0.000);
pPlayers = register_cvar("ff_players", "2", 0, 0.000);
pDelay = register_cvar("ff_delay", "1", 0, 0.000);
register_concmd("amx_addfake", "botadd", 8, "<# | @FILL> - add this many bots", -1);
register_concmd("amx_removefake", "botremove", 8, "<# | @ALL> - remove this many bots", -1);
set_task(10.000, "ServerStatus", 0, "", 0, "b", 0);
ReadNames();
new cvarString[256];
new shortName[16];
copy(shortName, 15, "ff");
register_cvar("jtp10181", "", 68, 0.000);
get_cvar_string("jtp10181", cvarString, 255);
if (strlen(cvarString))
{
if (contain(cvarString, shortName) == -1)
{
format(cvarString, 255, "%s,%s", cvarString, shortName);
set_cvar_string("jtp10181", cvarString);
}
}
else
{
formatex(cvarString, 255, shortName);
set_cvar_string("jtp10181", cvarString);
}
return 0;
}
public plugin_natives()
{
set_module_filter("module_filter");
set_native_filter("native_filter");
return 0;
}
public module_filter(String:module[])
{
!!! Removed Phi
if (!cstrike_running() && equali(module, "cstrike", 0))
{
return 1;
}
return 0;
}
public native_filter(String:name[], index, trap)
{
if (!trap)
{
return 1;
}
return 0;
}
public botadd(id, level, cid)
{
!!! Removed Phi
if (!cmd_access(id, level, cid, 1, false))
{
return 1;
}
new arg[10];
new botNum = 0;
if (read_argc() == 1)
{
botNum = 1;
}
else
{
read_argv(1, arg, 9);
if (equali(arg, "@FILL", 0))
{
botNum = get_maxplayers() - get_playersnum(1);
}
botNum = str_to_num(arg);
}
if (botNum <= 0 || botNum > get_maxplayers() - get_playersnum(1))
{
console_print(id, "[OhMyWay] Invalid number of bots to add");
return 1;
}
new Float:botDelay = get_pcvar_float(pDelay);
console_print(id, "[OhMyWay] Adding %d bots with %.1f second delay for each", botNum, botDelay);
set_task(botDelay, "createBot", 0, "", 0, "a", botNum);
set_task(botDelay * botNum + 1, "doneChanging", 0, "", 0, "", 0);
changingBots = 1;
return 1;
}
public botremove(id, level, cid)
{
!!! Removed Phi
if (!cmd_access(id, level, cid, 1, false))
{
return 1;
}
new arg[10];
new botNum = 0;
if (read_argc() == 1)
{
botNum = 1;
}
else
{
read_argv(1, arg, 9);
if (equali(arg, "@ALL", 0))
{
botNum = botCount;
}
botNum = str_to_num(arg);
}
if (botNum <= 0 || botNum > botCount)
{
console_print(id, "[OhMyWay] Invalid number of bots to remove");
return 1;
}
new Float:botDelay = get_pcvar_float(pDelay);
console_print(id, "[OhMyWay] Removing %d bots with %.1f second delay for each", botNum, botDelay);
set_task(botDelay, "removeBot", 0, "", 0, "a", botNum);
set_task(botDelay * botNum + 1, "doneChanging", 0, "", 0, "", 0);
changingBots = 1;
return 1;
}
public client_putinserver(id)
{
set_pev(id, pev_rendermode, 0);
is_user_ffbot[id] = 0;
ServerStatus();
return 0;
}
public client_disconnect(id)
{
is_user_ffbot[id] = 0;
ServerStatus();
return 0;
}
public createBot()
{
!!! Removed Phi
new bool:UseAnotherName = 0;
new BotName[33];
new UserNames[33][33];
UserNames[0] = 37420;
new name_rand = random_num(0, namesread + -1);
new endLoop = name_rand + -1;
if (0 > endLoop)
{
endLoop = namesread + -1;
}
new x = 1;
while (x <= 32)
{
if (is_user_connected(x))
{
get_user_name(x, UserNames[x], 32);
}
x++;
}
}
public removeBot()
{
new id = 1;
while (id <= 32)
{
if (is_user_ffbot[id][0][0])
{
server_cmd("kick #%d", get_user_userid(id));
is_user_ffbot[id] = 0;
botCount += -1;
return 0;
}
id++;
}
return 0;
}
public doneChanging()
{
changingBots = 0;
return 0;
}
public ServerStatus()
{
!!! Removed Phi
if (!get_pcvar_num(pAuto))
{
return 0;
}
if (checkingStatus || changingBots)
{
return 0;
}
checkingStatus = 1;
new rnd = 0;
if (0 < botCount)
{
new id = 1;
while (id <= 32)
{
if (is_user_connected(id))
{
if (!is_user_ffbot[id][0][0])
{
}
else
{
rnd = random_num(1, 100);
if (rnd <= 10)
{
set_user_frags(id, get_user_frags(id) + 1);
}
set_team(id);
new var2 = Heap_4;
var2[0] = 37880;
if (0 < get_user_team(id, var2, 0))
{
server_cmd("kick #%d", get_user_userid(id));
is_user_ffbot[id] = 0;
botCount += -1;
}
}
}
id++;
}
}
new pnum = get_playersnum(1);
new maxplayers = get_maxplayers();
new ff_players = get_pcvar_num(pPlayers);
new Float:botDelay = get_pcvar_float(pDelay);
if (maxplayers + -2 < ff_players)
{
ff_players = maxplayers + -2;
set_pcvar_num(pPlayers, ff_players);
}
if (botDelay <= 0.000)
{
log_amx("ERROR: Please set ff_delay to a number higher than 0");
}
else
{
if (ff_players > pnum)
{
new addnum = ff_players - pnum;
set_task(botDelay, "createBot", 0, "", 0, "a", addnum);
set_task(botDelay * addnum + 1, "doneChanging", 0, "", 0, "", 0);
changingBots = 1;
}
if (ff_players < pnum)
{
new removenum = pnum - ff_players;
removenum = min(removenum, botCount);
if (0 < removenum)
{
set_task(botDelay, "removeBot", 0, "", 0, "a", removenum);
set_task(botDelay * removenum + 1, "doneChanging", 0, "", 0, "", 0);
changingBots = 1;
}
}
}
checkingStatus = 0;
return 0;
}
public set_team(BotID)
{
if (cstrike_running())
{
cs_set_user_team(BotID, 0, _}:0);
}
return 0;
}
public ReadNames()
{
!!! Removed Phi
new botnames_file[128];
get_configsdir(botnames_file, 63);
format(botnames_file, 127, "%s/SpecBots.txt", botnames_file);
new botnames = fopen(botnames_file, "r");
if (botnames)
{
new data[35];
while (!feof(botnames))
{
if (namesread >= 256)
{
log_amx("MAX_NAMES exceeded, not all fake client names were able to load");
fclose(botnames);
}
fgets(botnames, data, 34);
trim(data);
new len = strlen(data);
if (0 >= len)
{
return 0;
}
if (data[len] - 1 == 10)
{
len--;
data[len] = 0;
}
if (equal(data, "", 0) || equal(data, "#", 1))
{
}
}
fclose(botnames);
}
else
{
new failmsg[128];
formatex(failmsg, 128, "Unable to read file \"%s\", it is required to load bot names from", botnames_file);
log_amx(failmsg);
set_fail_state(failmsg);
}
return 0;
}