/* Updated for LogD
 
Thanks Paegus for adding the kick-ass text to it, along with some other things!
Also, thanks to JoefromHB and infamous40ounce for some suggestions,
and to infected for reminding me to update it!
*/
 
/* $Id: plugin_milkman_camper.sma, v3.0 beta 2001/09/22 by Shady Milkman $ */
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
#define ACCESS_LOGD 131072
//READ THIS IF YOU WANT TO HARD CODE VALUES:*****
//I am using the vault file now, so these values really do nothing. Check the very bottom to hard code values
//Good to edit
//Weapon buying grace period...
new CAMPER_GRACEPERIOD = 10; //note: this will be in addition to the camper time!
/*tells whether to check for campers, enable with admin_campercheck 1 or on and disable*/
/*with admin_campercheck 0*/
new EnableCamperCheck = 1;
/*Number of Checks to fail before before accusation*/
new TOLERANCE_CHECKS=2; /* +1 initial cycle */
/*Number of seconds to move CAMPER_TOLERANCE from master coords before non-warning is marked.*/
new CAMPER_TIME=15;
/*how many units in any direction they have to have moved in order to not be considered a camper*/
/*150 is approximately 1 'noisy' step  */
new CAMPER_TOLERANCE=450;
/*number of warnings they have before they get kicked. -1 to disable this feature.*/
new CAMPER_WARNINGS = -1;
/*set to 1 if you want to slap a camper for every time they camp. 0 to disable.*/
new CAMPER_SLAP=1;
/*set this to which team is automatically checked. 0 for all, other for team #*/
new CAMPER_TEAM=0;
/*variable to auto start a camper checking vote*/
#define AUTO_CP_VOTE 0;
/*ratio of people who have to vote for camper-checking to turn on/off*/
#define CP_VOTE_RATIO 51;
/**************** THESE VARIABLES ARE NOT GOOD TO EDIT. REPEAT NOT ****************/
 
new STRING_VERSION[MAX_DATA_LENGTH] = "2.2 beta";
/*PlayerPosition[PLAYERINDEX] [0]=x coordinates, [1]=y coordinates, [2]=z coordinates*/
new PlayerPosition[MAX_PLAYERS][3];
/* Array for storing sub-warnings. This is to ensure they can leave an area and return */
new ToleranceCheck[MAX_PLAYERS];
/*Array that holds the number of warnings for each player.*/
new CamperWarnings[MAX_PLAYERS];
/*value that keeps track of the timer*/
new CamperTimer=0;
new First=1;
 
new Cycle = 1;
 
public CPVote() {
	new strDummy[10];
	if(vote_allowed()!=1){
		selfmessage("Camper_Vote: Voting not allowed at this time.");
		return PLUGIN_HANDLED;
	}
	vote("Camper-checking?", "Yes", "No", "HandleCPVote",strDummy);
	return PLUGIN_HANDLED;
}
 
public HandleCPVote(WinningOption,HLData,VoteCount,UserCount) {
	new Text[MAX_TEXT_LENGTH];
	new strNumber[MAX_NUMBER_LENGTH];
	new Ratio = CP_VOTE_RATIO;
	new strData[MAX_DATA_LENGTH];
	convert_string(HLData, strData,MAX_DATA_LENGTH);
 
	if (VoteCount >= Ratio*UserCount/100) {	
		if (WinningOption==1) {
			if(EnableCamperCheck==1) {
				centersay("Vote over. Camper-checking will stay.",18,249,244,0);
			} else {
				centersay("Vote successful. Camper-checking is on.",18,249,244,0);
				EnableCamperCheck=1;
			}
		} else {
			if(EnableCamperCheck==0) {
				centersay("Vote over. Camper-checking will remain disabled.",18,63,187,239);
			} else {
				centersay("Vote over. Camper-checking has been disabled.",18,63,187,239);
				EnableCamperCheck=0;
			}
		}
	} else {
		numtostr(Ratio*UserCount/100,strNumber);
		if(EnableCamperCheck==1) {
			snprintf(Text, MAX_TEXT_LENGTH, "Camper vote succeeded, but not enough votes for change (needed %s)^nCamper-checking will stay.", strNumber);
		} else {
			snprintf(Text, MAX_TEXT_LENGTH, "Camper vote succeeded, but not enough votes for change (needed %s)^nCamper-checking will remain disabled.", strNumber);
		}
		centersay(Text,18,63,187,239);
	}
}
 
/* Use this function for kicking campers.*/
public CamperKick(Name[]){
	new Text[MAX_TEXT_LENGTH];
	messageex(Name,"You have been kicked for camping.", print_console);
	snprintf(Text,MAX_TEXT_LENGTH,"%s has been kicked for camping.",Name);
	typesay(Text,6,250,90,100);
	kick(Name);
	return PLUGIN_CONTINUE;
}
 
public HandlePositions(iUser,Name[],x,y,z){
	new ox,oy,oz;
	ox=PlayerPosition[iUser][0];
	oy=PlayerPosition[iUser][1];
	oz=PlayerPosition[iUser][2];
	new Text[MAX_TEXT_LENGTH];
	/*
	Player must leave the volume (2xCAMPER_TOLERANCE)^3 to reset position check.
	remember 150 units is approx 1 noisy step*/
	if( ! (ox-x > CAMPER_TOLERANCE || ox-x < - CAMPER_TOLERANCE || 
	       oy-y > CAMPER_TOLERANCE || oy-y < - CAMPER_TOLERANCE ||
	       oz-z > CAMPER_TOLERANCE || oz-z < - CAMPER_TOLERANCE) ){
		if(ToleranceCheck[iUser]==0){ 
			/* Person has remained within CAMPER_TOLERANCE for TOLERANCE_CHECKS * CAMPER_TIME */
 
			/* This selects a color that is  in range: 25, 50, 100... 250*/
			new iRandRed = ( ( random(10) + 1 ) * 25 );
			new iRandGreen = ( ( random(10) + 1 ) * 25 );
			new iRandBlue = ( ( random(10) + 1 ) * 25 );
			/* for adjustable message-on-screen time for different length messages */
			new iDelay;
 
		   	/* He's a f*cking camper! */
			if(CAMPER_SLAP==1)
				slap(Name);
			if(CAMPER_WARNINGS==-1){
				/*Select a random Message in responce to campin make it more than*/
				switch( Cycle ){
				case  1:{
					snprintf(Text,MAX_TEXT_LENGTH,"Vote cast against player: %s",Name);
					iDelay = 3;
					}
				case  2:{
					snprintf(Text,MAX_TEXT_LENGTH,"Any Bets On When %s will Move?",Name);
					iDelay = 3;
					}
				case  3:{
					snprintf(Text,MAX_TEXT_LENGTH,"Hey everybody, %s is CAMPING!",Name);
					iDelay = 3;
					}
				case  4:{
					snprintf(Text,MAX_TEXT_LENGTH,"Hey %s, There are no Power-Ups in this game...",Name);
					iDelay = 4;
					}
				case  5:{
					snprintf(Text,MAX_TEXT_LENGTH,"Someday %s will learn a new trick.^nSuch as not camping?",Name);
					iDelay = 4;
					}
				case  6:{
					snprintf(Text,MAX_TEXT_LENGTH,"Can someone on %s's team teach 'em how to not camp?",Name);
					iDelay = 4;
					}
				case  7:{
					snprintf(Text,MAX_TEXT_LENGTH,"I think %s is a newbie cuz he's having trouble moving.",Name);
					iDelay = 4;
					}
				case  8:{
					snprintf(Text,MAX_TEXT_LENGTH,"I suddenly feel the need to camp!^nWon't you join me %s?",Name);
					iDelay = 4;
					}
				case  9:{
					snprintf(Text,MAX_TEXT_LENGTH,"All those marshmallows and %s isn't sharing!",Name);
					iDelay = 4;
					}
				case 10:{
					snprintf(Text,MAX_TEXT_LENGTH,"Today we rejoice with %s...^nFor finally getting the hang of camping!",Name);
					iDelay = 5;
					}
				case 11:{
					snprintf(Text,MAX_TEXT_LENGTH,"I sure hope %s is AFK (Away-From-Keyboard)^nHasn't moved in a while",Name);
					iDelay = 5;
					}
				case 12:{
					snprintf(Text,MAX_TEXT_LENGTH,"That's Ok %s, we understand...^nYou need to rest your legs... err Fingers...",Name);
					iDelay = 5;
					}
				case 13:{
					snprintf(Text,MAX_TEXT_LENGTH,"Move along %s. Nothing to see here!^n Oh I'm sorry... You're camping... My Bad.",Name);
					iDelay = 5;
					}
				case 14:{
					snprintf(Text,MAX_TEXT_LENGTH,"Hey %s, You have to Press your movement keys...^nElse I'll Think You're camping",Name);
					iDelay = 5;
					}
				case 15:{
					snprintf(Text,MAX_TEXT_LENGTH,"Motionless-Detector Acivated!^nAquiring Stationary Target.^nTarget Designation: %s",Name);
					iDelay = 5;
					}
				case 16:{
					snprintf(Text,MAX_TEXT_LENGTH,"Ummm... %s, Do you know what is worse than an AWP whore?^n...You are, you camping whore!",Name);
					iDelay = 6;
					}
				case 17:{
					snprintf(Text,MAX_TEXT_LENGTH,"Me Thinks %s is waiting for the mighty Quad-Damage to Re-Spawn...^nHey! This Aint Quake you camper!",Name);
					iDelay = 8;
					}
				case 18:{
					snprintf(Text,MAX_TEXT_LENGTH,"If %s doesn't stop camper soon^nI'll bury his ass... or her ass... ^nMmmm slap that booty!",Name);
					iDelay = 7;
					}
				case 19:{	/* Nice little dynamic one that displays useful info... */
					new MoveSec[MAX_NUMBER_LENGTH];
					new Steps[MAX_NUMBER_LENGTH];
					numtostr(CAMPER_TIME + CAMPER_TIME*TOLERANCE_CHECKS,MoveSec);
					numtostr(CAMPER_TOLERANCE/150,Steps);
					snprintf(Text,MAX_TEXT_LENGTH,"%s, I give you %s seconds to take %s steps.^nThen I call you a camper!",Name,MoveSec,Steps);
					iDelay = 6;
					}
				case 20:{
					snprintf(Text,MAX_TEXT_LENGTH,"This is great!^nI can randomly select messages for these worthless campers...^nI'm sure %s would agree if he was't so busy CAMPING!",Name);
					iDelay = 8;
					}
				case 21:{	/* Present this one as a vote question.. sorta.. could probly make an actual kick vote.. but nah... */
					snprintf(Text,MAX_TEXT_LENGTH,"Kick %s for Camping?^n1.) Yeah, give him the slipper!^n2.) No, I break 4 campers...",Name);
					iRandRed = 255;
					iRandGreen = 255;
					iRandBlue = 255;
					iDelay = 5;
					}
				case 22:{
					snprintf(Text,MAX_TEXT_LENGTH,"Could somebody wake %s up please.^nI think hes fallen asleep.",Name);
					iDelay = 4;
					}
				case 23:{
					snprintf(Text,MAX_TEXT_LENGTH,"I just took a poll of player positions.^nAnd %s has moved the least.",Name);
					iDelay = 4;
					}
				case 24:{	/* Another dynamic one if you happen to know the coords or the map.. yeah right... then you can go find him... */
					new Steps[MAX_NUMBER_LENGTH];
					numtostr(CAMPER_TOLERANCE/150,Steps);
					snprintf(Text,MAX_TEXT_LENGTH,"%s hasn't moved more than %s steps >from his last know position.^nLKP: %ix%ix%i^nHuh? Where-The-F**k is that?",Name,Steps,x,y,z);
					iDelay = 8;
					Cycle = 0;
					}
				default:{	/* Default event */
					snprintf(Text,MAX_TEXT_LENGTH,"%s is Camping",Name);
					iDelay = 3;
					}
				}
				Cycle+=1;
			} else{
				if(CamperWarnings[iUser]==0){
					CamperKick(Name);
					CamperWarnings[iUser]=CAMPER_WARNINGS;
					ToleranceCheck[iUser]=TOLERANCE_CHECKS;
					return PLUGIN_CONTINUE;
				}
				snprintf(Text,MAX_TEXT_LENGTH,"You are camping, please move.",CamperWarnings[iUser]);
				messageex(Name,Text, print_center);
				snprintf(Text,MAX_TEXT_LENGTH,"%s is camping, and has %i more warnings left.", Name, CamperWarnings[iUser]);
				CamperWarnings[iUser]=CamperWarnings[iUser]-1;
			}
 
			/* inform everyone that the dude is camping (in any particular color) */
			typesay(Text,iDelay,iRandRed,iRandGreen,iRandBlue);
 
			/* Since TOLERANCE_CHECKS have occured camper action was taken and value resets */
			ToleranceCheck[iUser]=TOLERANCE_CHECKS;
		} else {
			if( ToleranceCheck[iUser] == 1 ) { /* Last Warning if checks is set to 1??? */
				snprintf(Text,MAX_TEXT_LENGTH,"Please Move");
				messageex(Name,Text,print_center);
			}
			ToleranceCheck[iUser]=ToleranceCheck[iUser]-1;
		}
 
	} else {
		/* Player has left tolerance zone so reset Tolerance_Check for him */
		ToleranceCheck[iUser]=TOLERANCE_CHECKS;
	}
 
	/*If the user has left the tolerance range or has been accused of camping:
	  write their current position to our records */
	if(ToleranceCheck[iUser]==TOLERANCE_CHECKS){
	PlayerPosition[iUser][0]=x;
	PlayerPosition[iUser][1]=y;
	PlayerPosition[iUser][2]=z;
	} /* else retain previous position for next tolerance check */
	return PLUGIN_CONTINUE;
}
 
public RecordPositions(){
	new Dead;
	new i;
	new maxplayers = maxplayercount();
	new Name[MAX_NAME_LENGTH];
	new SessionID;
	new Team;
	new WONID;
	new x,y,z;
	if(EnableCamperCheck==0){
		return PLUGIN_CONTINUE;
	}
	if(First==1){
		First=0;
		for(i=0;i<maxplayers;i++){
			CamperWarnings[i]=CAMPER_WARNINGS;
			ToleranceCheck[i]=TOLERANCE_CHECKS;
		}
	}
	for (i=1; i<=maxplayers; i++) {
		if( playerinfo(i,Name,MAX_NAME_LENGTH,SessionID,WONID,Team,Dead)!=0){
			if(Dead==0) {
				if(CAMPER_TEAM==0 || Team==CAMPER_TEAM){
					if(check_immunity(Name)==0) {
						get_userorigin(Name,x,y,z);
						HandlePositions(i,Name,x,y,z);	
					}	
				}
			}
		}
	}
	return PLUGIN_CONTINUE;
}
 
public HandleSay(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
 
	convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
 
	strstripquotes(Data);
	new Match = FALSE;
	if (strcasestr(Data, "camper-check")!=-1) {
		Match = TRUE;
	} else if (strcasestr(Data, "camper check")!=-1) {
		Match = TRUE;
	}
	if (Match==TRUE) {
		if (EnableCamperCheck == 1){ 
			centersay ("Camper checking is on! ^nDon't camp.",7,0,255,0); 
		} else {
			centersay ("Camper checking is off. ^nJust don't make it stupid ",7,0,255,0);
		}
	}
	if(strcasestr(Data, "vote_camper")!=-1){
		CPVote();
	}
	return PLUGIN_CONTINUE;
}
 
public admin_vote_camper(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
 
	if (vote_allowed()!=1) {
		selfmessage( "Vote not allowed at this time.");
		return PLUGIN_HANDLED;
	}
 
	convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
	say_command(User,Command,Data);		
	CPVote();
	return PLUGIN_HANDLED;
}
public admin_camperteam(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
	new Text[MAX_TEXT_LENGTH];
	new temp_team;
	convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
	if (strlen(Data)==0) {
		snprintf(Text,MAX_TEXT_LENGTH,"Camper team: %i",CAMPER_TEAM);
		selfmessage(Text);
	}else{
		temp_team=strtonum(Data);
		CAMPER_TEAM=temp_team;
		snprintf(Text,MAX_TEXT_LENGTH,"Camper team: %i",CAMPER_TEAM);
		selfmessage(Text);
	}
	new NumString[MAX_TEXT_LENGTH];
	numtostr(CAMPER_TEAM,NumString);
	set_vaultdata("admin_camperteam",NumString);
	say_command(User,Command,Data);
	return PLUGIN_HANDLED;
}
 
public admin_campercheck(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
	new Text[MAX_TEXT_LENGTH];
 
	convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
	if (strlen(Data)==0) {
		snprintf(Text,MAX_TEXT_LENGTH,"Camper checking: %i",EnableCamperCheck);
		selfmessage(Text);
	}
	else if(check_param(Data)==1) {
		selfmessage("Camper checking: 1");
		EnableCamperCheck=1;
	} else {
		selfmessage("Camper checking: 0");
		EnableCamperCheck=0;
	}
	new NumString[MAX_TEXT_LENGTH];
	numtostr(EnableCamperCheck,NumString);
	set_vaultdata("admin_campercheck",NumString);
	say_command(User,Command,Data);
	return PLUGIN_HANDLED;
}
public admin_campert(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
	new Text[MAX_TEXT_LENGTH];
	convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
	new temp_tol=0;
	if (strlen(Data)==0) {
		snprintf(Text,MAX_TEXT_LENGTH,"Camper tolerance: %i",CAMPER_TOLERANCE);
		selfmessage(Text);
	} else{
		temp_tol=strtonum(Data);
		CAMPER_TOLERANCE=temp_tol;
		snprintf(Text,MAX_TEXT_LENGTH,"Camper tolerance: %i",CAMPER_TOLERANCE);
		selfmessage(Text);
	}
	new NumString[MAX_TEXT_LENGTH];
	numtostr(CAMPER_TOLERANCE,NumString);
	set_vaultdata("admin_campert",NumString);
	say_command(User,Command,Data);
	return PLUGIN_HANDLED;
}
public admin_campertime(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
	new Text[MAX_TEXT_LENGTH];
	convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
	new temp_time=0;
	if (strlen(Data)==0) {
		snprintf(Text,MAX_TEXT_LENGTH,"Camper time: %i",CAMPER_TIME);
		selfmessage(Text);
	} else{
		temp_time=strtonum(Data);
		CAMPER_TIME=temp_time;
		kill_timer(CamperTimer);
		CamperTimer=set_timer("RecordPositions",CAMPER_TIME,9999);
		snprintf(Text,MAX_TEXT_LENGTH,"Camper time: %i",CAMPER_TIME);
		selfmessage(Text);
	}
	new NumString[MAX_TEXT_LENGTH];
	numtostr(CAMPER_TIME,NumString);
	set_vaultdata("admin_campertime",NumString);
	say_command(User,Command,Data);
	return PLUGIN_HANDLED;
}
public admin_camperslap(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
	new Text[MAX_TEXT_LENGTH];
	convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
	if (strlen(Data)==0) {
		snprintf(Text,MAX_TEXT_LENGTH,"Camper slap: %i",CAMPER_SLAP);
		selfmessage(Text);
	} else if(check_param(Data)==1){
		CAMPER_SLAP=1;
		snprintf(Text,MAX_TEXT_LENGTH,"Camper slap: %i",CAMPER_SLAP);
		selfmessage(Text);
	}else{
		CAMPER_SLAP=0;
		snprintf(Text,MAX_TEXT_LENGTH,"Camper slap: %i",CAMPER_SLAP);
		selfmessage(Text);
	}
	new NumString[MAX_TEXT_LENGTH];
	numtostr(CAMPER_SLAP,NumString);
	set_vaultdata("admin_camperslap",NumString);
	say_command(User,Command,Data);
	return PLUGIN_HANDLED;
}
 
public admin_campergrace(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
	new Text[MAX_TEXT_LENGTH];
	convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
	if (strlen(Data)==0) {
		snprintf(Text,MAX_TEXT_LENGTH,"Camper grace: %i",CAMPER_GRACEPERIOD);
		selfmessage(Text);
	} else{
		CAMPER_GRACEPERIOD=strtonum(Data);
		snprintf(Text,MAX_TEXT_LENGTH,"Camper grace: %i",CAMPER_GRACEPERIOD);
		selfmessage(Text);
	}
	new NumString[MAX_TEXT_LENGTH];
	numtostr(CAMPER_GRACEPERIOD,NumString);
	set_vaultdata("admin_campergrace",NumString);
	say_command(User,Command,Data);
	return PLUGIN_HANDLED;
}
public admin_camperswarn(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
	new Text[MAX_TEXT_LENGTH];
	new i;
	convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
	new temp_tol=0;
	if (strlen(Data)==0) {
		snprintf(Text,MAX_TEXT_LENGTH,"Camper sub-warnings: %i",TOLERANCE_CHECKS);
		selfmessage(Text);
	} else{
		temp_tol=strtonum(Data);
		CAMPER_WARNINGS=temp_tol;
		snprintf(Text,MAX_TEXT_LENGTH,"Camper sub-warnings: %i",TOLERANCE_CHECKS);
		selfmessage(Text);
		for	(i=i;i<=MAX_PLAYERS;i++){
			ToleranceCheck[i]=TOLERANCE_CHECKS;
		}
	}
	new NumString[MAX_TEXT_LENGTH];
	numtostr(TOLERANCE_CHECKS,NumString);
	set_vaultdata("admin_campersubwarn",NumString);
	say_command(User,Command,Data);
	return PLUGIN_HANDLED;
}
 
public admin_camperwarn(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
	new Text[MAX_TEXT_LENGTH];
	new i;
	convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
	new temp_tol=0;
	if (strlen(Data)==0) {
		snprintf(Text,MAX_TEXT_LENGTH,"Camper warnings: %i",CAMPER_WARNINGS);
		selfmessage(Text);
	} else{
		temp_tol=strtonum(Data);
		CAMPER_WARNINGS=temp_tol;
		snprintf(Text,MAX_TEXT_LENGTH,"Camper warnings: %i",CAMPER_WARNINGS);
		selfmessage(Text);
		for	(i=i;i<=MAX_PLAYERS;i++){
			CamperWarnings[i]=CAMPER_WARNINGS;
			ToleranceCheck[i]=TOLERANCE_CHECKS;
		}
	}
	new NumString[MAX_TEXT_LENGTH];
	numtostr(CAMPER_WARNINGS,NumString);
	set_vaultdata("admin_camperwarn",NumString);
	say_command(User,Command,Data);
	return PLUGIN_HANDLED;
}
public logd_world(HLCommand,HLData,HLUserName,UserIndex)
{
	new Params[MAX_DATA_LENGTH];
	convert_string(HLData,Params,MAX_DATA_LENGTH);
	if(strcmp(Params,"Round_Start")==0){
		new i;
		for(i=0;i<MAX_PLAYERS;i++){
			PlayerPosition[i][0]=0;
			PlayerPosition[i][1]=0;
			PlayerPosition[i][2]=0;
		}
 
 
		kill_timer(CamperTimer);
		set_timer("BringBackTheTimer",CAMPER_GRACEPERIOD,0);
	}
	return PLUGIN_CONTINUE;
}
public BringBackTheTimer(){
	CamperTimer=set_timer("RecordPositions",CAMPER_TIME,9999);
}
public plugin_init() {
 
	/*Don't edit below this, please. I put lots of hard work into this plugin.*/
	plugin_registerinfo("Shady Milkman's Anti-Camper plugin (Modified: Paegus)","Auto detects, announces, warns, slaps, and kicks campers.",STRING_VERSION);
	plugin_registercmd("admin_campercheck","admin_campercheck",ACCESS_KICK,"Enables 1/0 Disables checking for campers.");
	plugin_registercmd("admin_campert","admin_campert",ACCESS_KICK,"admin_campert <tolerance> Sets/displays camper tolerance in units.");
	plugin_registercmd("admin_campertime","admin_campertime",ACCESS_KICK,"admin_campertime <time> Sets/displays camper time check in seconds.");
	plugin_registercmd("admin_camperslap","admin_camperslap",ACCESS_KICK,"admin_camperslap <value> Enables/disables and displays the current setting of camperslap.");
	plugin_registercmd("admin_camperwarn","admin_camperwarn",ACCESS_KICK,"admin_camperwarn <value> Sets/displays number of camper warnings. Resests warnings.");
	plugin_registercmd("admin_camperswarn","admin_camperswarn",ACCESS_KICK,"admin_camperswarn <value> Sets/displays number of camper sub-warnings warnings. Resests warnings.");
	plugin_registercmd("admin_campergrace","admin_campergrace",ACCESS_KICK,"admin_campergrace <value> Sets/displays number of seconds for grace period.");
	plugin_registercmd("admin_vote_camper","admin_vote_camper",ACCESS_ALL,"admin_vote_camper: starts a vote for camper-checking.");
	plugin_registercmd("admin_camperteam","admin_camperteam",ACCESS_KICK,"admin_camperteam <team> Sets which team is checked for camping.");
	plugin_registercmd("say","HandleSay",ACCESS_ALL);
	plugin_registercmd("logd_world","logd_world",ACCESS_LOGD);
	plugin_registerhelp("say vote_camper",ACCESS_ALL,"say vote_camper: Starts a vote for camper-checking.");
	CamperTimer=set_timer("RecordPositions", CAMPER_TIME,9999);
	exec("logd_reg 62 admin_command logd_world");
 
#if AUTO_CP_VOTE==1	
	set_timer("CPVote",610,1);
#endif
 
	new StrValue[MAX_TEXT_LENGTH];
	//****loads the values from the vault file ***
	if(!get_vaultdata("admin_campercheck", StrValue,10))
		set_vaultdata("admin_campercheck","1");
	get_vaultdata("admin_campercheck",StrValue,10);
	EnableCamperCheck=strtonum(StrValue);
 
	if(!get_vaultdata("admin_campert", StrValue,10))
		set_vaultdata("admin_campert","450");
	get_vaultdata("admin_campert",StrValue,10);
	CAMPER_TOLERANCE=strtonum(StrValue);
 
	if(!get_vaultdata("admin_camperslap", StrValue,10))
		set_vaultdata("admin_camperslap","1");
	get_vaultdata("admin_camperslap",StrValue,10);
	CAMPER_SLAP=strtonum(StrValue);
 
	if(!get_vaultdata("admin_campertime", StrValue,10))
		set_vaultdata("admin_campertime","15");
	get_vaultdata("admin_campertime",StrValue,10);
	CAMPER_TIME=strtonum(StrValue);
 
	if(!get_vaultdata("admin_camperwarn", StrValue,10))
		set_vaultdata("admin_camperwarn","-1");
	get_vaultdata("admin_camperwarn",StrValue,10);
	CAMPER_WARNINGS=strtonum(StrValue);
 
	if(!get_vaultdata("admin_camperteam", StrValue,10))
		set_vaultdata("admin_camperteam","0");
	get_vaultdata("admin_camperteam",StrValue,10);
	CAMPER_TEAM=strtonum(StrValue);
 
	if(!get_vaultdata("admin_campersubwarn", StrValue,10))
		set_vaultdata("admin_campersubwarn","2");
	get_vaultdata("admin_campersubwarn",StrValue,10);
	TOLERANCE_CHECKS=strtonum(StrValue);
 
 
	if(!get_vaultdata("admin_campergrace", StrValue,10))
		set_vaultdata("admin_campergrace","10");
	get_vaultdata("admin_campergrace",StrValue,10);
	CAMPER_GRACEPERIOD=strtonum(StrValue);
 
	return PLUGIN_CONTINUE;
}