/* Black Knight's Anti-Stats-Cheater Plugin v1.1 (03.09.2002)
Ever being annoyed by people begin defusing too often. You can push your Psychostats skill
this way very easy, if the award is given (default).
This plugin will slap him after 4 tries and slays him after 6.
This is a CS-only plugin. Hmm, I think this is obvious ;) */
 
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
#define ACCESS_CONSOLE 131072
 
new STRING_VERSION[MAX_DATA_LENGTH] = "1.1";
 
new playerarray[MAX_PLAYERS]={0,...};
new planted = 0;
 
public check_asc_defuse(HLCommand,HLData,HLUserName,UserIndex) {
	new Data[MAX_DATA_LENGTH];
	new first[MAX_DATA_LENGTH];
	new second[MAX_DATA_LENGTH];
	new pindex;
 
	convert_string(HLData,Data,MAX_DATA_LENGTH);
 
	if(Data[2] == 'P') {
		planted=1;
		init_array();
	}
	if(Data[2] == 'B') {
		strbreak(Data, first, second, MAX_DATA_LENGTH);
		pindex=strtonum(first);
		playerarray[pindex]+=1;
		new strName[MAX_NAME_LENGTH];
		playerinfo(pindex,strName,MAX_NAME_LENGTH);
		if(playerarray[pindex]==4){
			slap(strName);
			messageex(strName,"WARNING! Statscheater not allowed on this server! Defuse once!",print_console);
			messageex(strName,"WARNING! Statscheater not allowed on this server!^nDefuse once!",print_tty);
		}
		if(playerarray[pindex]>=7){
			slay(strName);
			messageex(strName,"Statscheater not allowed on this server! Defuse once!",print_console);
			messageex(strName,"Statscheater not allowed on this server!^nDefuse once!",print_tty);
		}
	}
	return PLUGIN_CONTINUE;
}
 
public check_asc_round(HLCommand,HLData,HLUserName,UserIndex) {
	new Params[MAX_DATA_LENGTH];
 
	convert_string(HLData,Params,MAX_DATA_LENGTH);
	if(Params[6]=='E' || Params[6]=='D' || Params[6]=='S'){
		planted=0;
		init_array();
	}
	return PLUGIN_CONTINUE;
}
 
init_array() {
	new i;
	for(i=0;i<=MAX_PLAYERS;i++){
		playerarray[i]=0;
	}
	return PLUGIN_CONTINUE;
}
 
public check_asc_kill(HLCommand,HLData,HLUserName,UserIndex){
	if(planted==1){
		new Data[MAX_DATA_LENGTH];
		new sIDA[10],sIDV[10];
		new IDA;
		convert_string(HLData,Data,MAX_DATA_LENGTH);
		strbreak(Data,sIDA,sIDV,10);
		IDA=strtonum(sIDA);
		playerarray[IDA]=0;
	}
	return PLUGIN_CONTINUE;
}
 
 
public plugin_init() {
	new curmap[MAX_DATA_LENGTH];
	currentmap(curmap,MAX_DATA_LENGTH);
	if(curmap[0]=='d' || curmap[0]=='D'){
		plugin_registerinfo("BKs Anti-Stats-Cheater Plugin","Slaps and slays people begin defusing too often",STRING_VERSION);
		plugin_registercmd("check_asc_defuse", "check_asc_defuse", ACCESS_CONSOLE);
		plugin_registercmd("check_asc_round", "check_asc_round", ACCESS_CONSOLE);
		plugin_registercmd("check_asc_kill", "check_asc_kill", ACCESS_CONSOLE);
 
		exec( "logd_reg 60 admin_command check_asc_defuse" );
		exec( "logd_reg 62 admin_command check_asc_round" );
		exec( "logd_reg 57 admin_command check_asc_kill");
	}
	else{
		plugin_registerinfo("BKs Anti-Stats-Cheater Plugin","Disabled! No defusion map!",STRING_VERSION);
	}
	return PLUGIN_CONTINUE;
}