/*
 * Admin mod script. Copyright (C) 2000, Alfred Reynolds.
 * $Id: plugin_bot.sma,v beta 0.1 Wraith, Exp $
 *
 Should be working on Steam-Servers now ([WING] Black Knight)
*/
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
#define ACCESS_BOT 1024
#define REALBOT 1
 
new STRING_VERSION[MAX_DATA_LENGTH] = "beta 2.50.0";
 
public admin_addbot(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	//new TargetName[MAX_NAME_LENGTH];
	new Text[MAX_TEXT_LENGTH];
	new User[MAX_NAME_LENGTH];
 
	convert_string(HLCommand,Command,MAX_NAME_LENGTH);
	convert_string(HLData,Data,MAX_NAME_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
 
	if (access(ACCESS_BOT,"") == 1) {
#if REALBOT == 1
		snprintf(Text,MAX_TEXT_LENGTH,"bot addrb");
#else
		snprintf(Text,MAX_TEXT_LENGTH,"bot addbot");
#endif
		exec(Text);
	}
	return PLUGIN_HANDLED;
}
 
#if REALBOT == 1
/* This section is for realbot only commands, the removebots kicks all bots by lookign for a wonid of 0 and 
 kicking if it finds it, it will work as long as no player has a wonid of 0 which will only afect one person
 worldwide, if by my bad luck they happen to be using this script i apologise :-) 
*/
public admin_fillserver(HLCommand,HLData,HLUserName,UserIndex) {	
	if (access(ACCESS_BOT,"") == 1) {
		exec("bot fillserver");
	}
	return PLUGIN_HANDLED;
}
 
public admin_rb_chat(HLCommand,HLData,HLUserName,UserIndex) {	
	if (access(ACCESS_BOT,"") == 1) {
		exec("bot rb_chat");
	}
	return PLUGIN_HANDLED;
}
 
public admin_rb_quiet(HLCommand,HLData,HLUserName,UserIndex) {	
	if (access(ACCESS_BOT,"") == 1) {
		exec("bot rb_shutup");
	}
	return PLUGIN_HANDLED;
}
 
public admin_removebots(HLCommand,HLData,HLUserName,UserIndex) {
	new SessionID;
	new Team;
	new Dead;
	new WONID;
	new Name[MAX_NAME_LENGTH];
	new iMaxPlayers = maxplayercount();
	new i;
	new sAuthID[MAX_AUTHID_LENGTH];
 
	for (i = 1; i <= iMaxPlayers; i++) {
		if(playerinfo(i,Name,MAX_NAME_LENGTH,SessionID,WONID,Team,Dead,sAuthID)==1) {
			if ( streq(sAuthID,"BOT") ) {
				kick(Name);
			}
		}
	}
 
}
#else
/* this secion is for all those podbot commands, i don't and haven't use podbot so if there are problems 
 come to the boards and tell me about them and how to fix them. 
*/
public admin_killbots(HLCommand,HLData,HLUserName,UserIndex) {	
	if (access(ACCESS_BOT,"") == 1) {
		exec("bot killbots");
	}
	return PLUGIN_HANDLED;
}
 
public admin_fill5(HLCommand,HLData,HLUserName,UserIndex) {	
	if (access(ACCESS_BOT,"") == 1) {
		exec("bot fillserver 5");
	}
	return PLUGIN_HANDLED;
}
 
public admin_fill1(HLCommand,HLData,HLUserName,UserIndex) {	
	if (access(ACCESS_BOT,"") == 1) {
		exec("bot fillserver 1");
	}
	return PLUGIN_HANDLED;
}
 
public admin_fill2(HLCommand,HLData,HLUserName,UserIndex) {	
	if (access(ACCESS_BOT,"") == 1) {
		exec("bot fillserver 2");
	}
	return PLUGIN_HANDLED;
}
 
public admin_removebots(HLCommand,HLData,HLUserName,UserIndex) {	
	if (access(ACCESS_BOT,"") == 1) {
		exec("bot removebots");
	}
	return PLUGIN_HANDLED;
}
#endif
 
 
public plugin_init() {
	plugin_registerinfo("Plugin allow Admin control of Bots.","Plugin to log users commands.",STRING_VERSION);
	plugin_registercmd("admin_addbot","admin_addbot",ACCESS_BOT,"admin_addbot: Adds a bot. Parameters are as normal for the Bot");
#if REALBOT==1
	plugin_registercmd("admin_rb_chat","admin_rb_chat",ACCESS_BOT,"admin_rb_chat: Lets bots chat.");
	plugin_registercmd("admin_removebots","admin_removebots",ACCESS_BOT,"admin_removebots: Disconnects all Bots from the game.");
	plugin_registercmd("admin_rb_quiet","admin_rb_quiet",ACCESS_BOT,"admin_rb_quiet: Stops bots chatting.");
	plugin_registercmd("admin_fillserver","admin_fillserver",ACCESS_BOT,"admin_fillserver: Fills server with Bots.");
#else
	plugin_registercmd("admin_removebots","admin_removebots",ACCESS_BOT,"admin_removebots: Disconnects all Bots from the game.");
	plugin_registercmd("admin_killbots","admin_killsbots",ACCESS_BOT,"admin_killbots: Kills all Bots.");
	plugin_registercmd("admin_fill_5","admin_fill5",ACCESS_BOT,"admin_fill5: Fills server with auto-assigned Bots.");
	plugin_registercmd("admin_fill_1","admin_fill1",ACCESS_BOT,"admin_fill5: Fills server with Terrorist Bots.");
	plugin_registercmd("admin_fill_2","admin_fill2",ACCESS_BOT,"admin_fill5: Fills server with Counter-Terrorist Bots.");
#endif
	return PLUGIN_CONTINUE;
}