new const VERSION[] = "0.1.1b";
register_plugin("Spectator Bot",VERSION,"b0t.");
get_configsdir(szConfigsDir,charsmax(szConfigsDir));
add(szConfigsDir,charsmax(szConfigsDir),"/");
add(szConfigsDir,charsmax(szConfigsDir),CONFIG_NAME);
Func__CreateFile(szConfigsDir);
Func__ReadFile(szConfigsDir);
g_iMaxBotNum = ArraySize(g_a_BotName);
g_a_BotId = ArrayCreate();
TaskFunc__BotConnected();
public TaskFunc__BotConnected() {
for(new pBot,szName[32];g_iBotNum<g_iMaxBotNum;++g_iBotNum) {
ArrayGetString(g_a_BotName,g_iBotNum,szName,charsmax(szName));
pBot = engfunc(EngFunc_CreateFakeClient,szName);
if(!is_user_connected(pBot)) {
dllfunc(MetaFunc_CallGameEntity,"player",pBot);
set_pev(pBot,pev_flags,FL_PROXY);
set_pev(pBot,pev_flags,FL_FAKECLIENT);
set_pev(pBot,pev_team,CS_TEAM_UNASSIGNED);
ArrayPushCell(g_a_BotId,pBot);
public client_connect(id) {
new pBot = ArrayGetCell(g_a_BotId,g_iBotNum);
server_cmd("kick #%i",get_user_userid(pBot));
public client_disconnected(id) {
new iItem = ArrayFindValue(g_a_BotId,id);
ArrayDeleteItem(g_a_BotId,iItem);
RequestFrame("RequestFrame_client_disconnected");
public RequestFrame_client_disconnected() {
TaskFunc__BotConnected();
public Func__CreateFile(const szFile[]) {
write_file(szFile,";Кількість зарезервованих слотів");
write_file(szFile,"empty_slot = 2");
write_file(szFile,";Спосіб відображення ботів");
write_file(szFile,"; 0 - Проксі(будуть відображатися в стовпці гравців)");
write_file(szFile,"; 1 - Фейковий клієнт(будуть відображатися в стовпці ботів)");
write_file(szFile,"display_type = 1");
write_file(szFile,";Ім'я бота");
write_file(szFile,"vk.com");
write_file(szFile,"server.ru");
public Func__ReadFile(const szFile[]) {
new f = fopen(szFile,"r");
g_a_BotName = ArrayCreate(32);
while(fgets(f,szData,charsmax(szData))) {
new szLeft[64],szRight[64];
strtok2(szData,szLeft,charsmax(szLeft),szRight,charsmax(szRight),'=',TRIM_FULL);
if(equal(szLeft,"empty_slot"))
g_iMaxEmptySlots = str_to_num(szRight);
g_iDisplayType = str_to_num(szRight);
ArrayPushString(g_a_BotName,szData);
stock bool:CanConnect() {
return bool:(get_empty_slots() > g_iMaxEmptySlots);