/**************************************************************************************************
***	Plugin_LogD_teamselect	***	by [HDK]DragonReborn	***	[11-05-2001][v1.1]	***
***************************************************************************************************
*
* Instructions
* ------------
* - *** Requires LogD ***
* -Just compile this file and put in your dlls folder for server
*	(ex. c:\sierra\half-life\cstrike\dlls)
* -Then in the plugin.ini file add this line at the bottom:	dlls/plugin_logd_teamselection.amx
* -Simply makes all connecting players choose autoteamselct to stop newbies or winning team followers
* _________________________________________________________________________________________________
* Commands
* --------
*	-admin_autoteams <1/0> : turns autoteam selection on/off
*		[on by default - change Request = 1; to Request = 0; to disable selection as default]
*
* _________________________________________________________________________________________________
* ChangeLog
* ---------
* -NEW to 1.1
*	-Added ability to turn autoteam selection on/off in game using:
*					admin_autoteams <1/0>
*
**************************************************************************************************/
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
#define ACCESS_CONSOLE 131072
#define ACCESS_AUTOTEAM 4096
 
new STRING_VERSION[MAX_DATA_LENGTH] = "1.1";
 
new User[MAX_NAME_LENGTH];
new Request = 1;
 
public logd_teamselect(HLCommand,HLData,HLUserName) {
 
	new sID[MAX_DATA_LENGTH];
	new Data[MAX_DATA_LENGTH];
 
	convert_string(HLData, Data, MAX_DATA_LENGTH);
	strbreak(Data, sID, Data, MAX_DATA_LENGTH);
 
	new iID = strtonum( sID );
	if( !playerinfo(iID,User,MAX_NAME_LENGTH) ) {
		return PLUGIN_FAILURE;
	}
 
	if(Request == 1) {
		execclient(User,"+attack");
		execclient(User,"menuselect 5");
		execclient(User,"menuselect 5");
		execclient(User,"-attack");
	}
 
	return PLUGIN_HANDLED;
}
 
public admin_autoteams(HLCommand,HLData,HLUserName,UserIndex) {
 
	new Data[MAX_DATA_LENGTH];
	new Toggle;
 
	convert_string(HLData, Data, MAX_DATA_LENGTH);
 
	if (strlen(Data) > 0) {
		Toggle = strtonum(Data);
		if (Toggle == 1) {
			Request = 1;
			selfmessage("[ Auto Team Selection has been activated. ]");
			centersay("Auto Team Selection has been enabled on the server",5,0,255,0);
		}else if (Toggle == 0) {
			Request = 0;
			selfmessage("[ Auto Team Selection has been deactivated. ]");
			centersay("Auto Team Selection has been disabled on the server",5,0,255,0);
		}else {
			Toggle = -1;
			selfmessage("[ Command not issued correctly, 1=on, 0=off ]");
		}
	}else {
		selfmessage("[ Command not issued correctly, 1=on, 0=off ]");
	}
 
	return PLUGIN_HANDLED;
 
}
 
public plugin_init() {
	plugin_registerinfo("Plugin_LogD_Autoteamselect","Auto player team selection for incoming players to server.",STRING_VERSION);
	plugin_registercmd("logd_teamselect", "logd_teamselect", ACCESS_CONSOLE, "");
	plugin_registercmd("admin_autoteams", "admin_autoteams", ACCESS_AUTOTEAM, "admin_autoteams <#>: Toggles auto player team selection(1=on/0=off)");
 
	exec( "logd_reg 51 admin_command logd_teamselect" );
 
	return PLUGIN_CONTINUE;
}