/* DMZ Votes -=- Version 1.1 */
/* Plugin Made By: [ph34r] Mr. Satan */
/* MM/DD/YYYY -- 10/20/02 @ 1:128pm */
/* http://clan_ph34r.dk3.com */
/* Originally PLUGIN_SHARP_GRAVITY & PLUGIN_VOTE_FUNMODE */
/* This Will Allow People On The Server To Vote For Any Anti-Kill, Ki-Base, Ki Per Kill, & Max Timeout. Example: admin_vote_kibase 5000 : Will Vote To Change Ki Baee to 5000 */
/* If You Want To Edit This You May, But You Must Mention My Name As The Orignal Creator & Mention The Plugins I Used To Create This One */
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
#define ACCESS_VOTE_ANTIKILL ACCESS_VOTE_KICK
#define ACCESS_VOTE_KIBASE ACCESS_VOTE_KICK
#define ACCESS_VOTE_KIPERKILL ACCESS_VOTE_KICK
#define ACCESS_VOTE_MAXTIMEOUT ACCESS_VOTE_KICK
#define ANTIKILL_VOTE_RATIO 60
#define KIBASE_VOTE_RATIO 60
#define KIPERKILL_VOTE_RATIO 60
#define MAXTIMEOUT_VOTE_RATIO 60
 
new STRING_VERSION[MAX_DATA_LENGTH] = "2.50.0";
new LogFile[]="Logs.txt";
 
public AntiKillVote() {
	new strDummy[10];
	vote("Enable/Disable The Kill Command?", "Yes", "No", "HandleAntiKillVote",strDummy);
}
 
public HandleAntiKillVote(WinningOption,HLData,VoteCount,UserCount) {
	new Text[MAX_TEXT_LENGTH];
	new strNumber[MAX_NUMBER_LENGTH];
	new Ratio = ANTIKILL_VOTE_RATIO;
	new strData[MAX_DATA_LENGTH];
	convert_string(HLData, strData,MAX_DATA_LENGTH);
 
	if (VoteCount >= Ratio*UserCount/100) {	
		if (WinningOption==1) {
			if(getvar("sv_antikill")==1) {
				centersay("--:: The KILL Command Will Remain [DISABLED] ::--",18,0,255,255);
			} else {
				centersay("--:: The KILL Command Is Now [ENABLED] ::--",18,0,255,255);
				exec("sv_antikill 0");
			}
		} else {
			if(getvar("sv_antikill")==1) {
				centersay("--:: The KILL Will Remain [DISABLED] ::--",18,255,255,0);
				exec("sv_antikill 1");
			} else {
				centersay("--:: The KILL Command Is Now [ENABLED] ::--",18,255,255,0);
			}
		}
	} else {
		numtostr(Ratio*UserCount/100,strNumber);
		if(getvar("admin_fun_mode")==1) {
			snprintf(Text, MAX_TEXT_LENGTH, "--:: Anti-Kill Vote Succeeded ~ But Not Enough Votes For Change (Needed %s) ::--^nFun Mode Will Remain [ENABLED]", strNumber);
		} else {
			snprintf(Text, MAX_TEXT_LENGTH, "--:: Anti-Kill Vote Succeeded ~ But Not Enough Votes For Change (Needed %s) ::--^nFun Mode Will Remain [DISABLED]", strNumber);
		}
		centersay(Text,18,255,255,255);
	}
}
 
public admin_vote_antikill(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);		
	AntiKillVote();
	return PLUGIN_HANDLED;
}
 
public admin_vote_kibase(HLCommand,HLData,HLUser,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
	new Text[MAX_TEXT_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(HLUser,User,MAX_NAME_LENGTH);
	getvar("sv_kibase");
	snprintf(Text, MAX_TEXT_LENGTH, "Change Ki Base To %s ?", Data);
	log(Text);
	vote(Text,"Yes","No","HandleKiBaseVote",Data);
	say_command(User,Command,Data);
	snprintf(Text, MAX_TEXT_LENGTH, "[ADMIN] %s Used Admin_Command %s %s.", User, Command, Data);
	writefile(LogFile, Text);
	return PLUGIN_HANDLED;
}
 
public HandleKiBaseVote(WinningOption,HLKiBase,VoteCount,UserCount) {
	new strNumber[MAX_NUMBER_LENGTH];
	new Text[MAX_TEXT_LENGTH];
	new strKiBase[MAX_DATA_LENGTH];
	new Ratio = KIPERKILL_VOTE_RATIO;
	convert_string(HLKiBase,strKiBase,MAX_DATA_LENGTH);
 
	if (WinningOption == 1) {
		if (VoteCount >= Ratio*UserCount/100) {
			snprintf(Text, MAX_TEXT_LENGTH, "--:: Changing Ki Base To %s Due To A Vote ::--", strKiBase);
			say(Text);
			setstrvar("admin_quiet", "2");
			setstrvar("sv_kibase", strKiBase);
			setstrvar("admin_quiet", "2");
		} else {
			numtostr(Ratio*UserCount/100,strNumber);
			snprintf(Text, MAX_TEXT_LENGTH, "--:: Ki Base Vote Succeded But Not Enough To Change (Needed %s) ::--", strNumber);
			say(Text);
		}
	} else {
		say("--:: Ki Base Vote Failed ::--");
	}
}
 
public admin_vote_kikill(HLCommand,HLData,HLUser,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
	new Text[MAX_TEXT_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(HLUser,User,MAX_NAME_LENGTH);
	getvar("sv_kiperkill");
	snprintf(Text, MAX_TEXT_LENGTH, "Change Ki Per Kill To %s ?", Data);
	log(Text);
	vote(Text,"Yes","No","HandleKiPerKillVote",Data);
	say_command(User,Command,Data);
	snprintf(Text, MAX_TEXT_LENGTH, "[ADMIN] %s Used Admin_Command %s %s.", User, Command, Data);
	writefile(LogFile, Text);
	return PLUGIN_HANDLED;
}
 
public HandleKiPerKillVote(WinningOption,HLKiPerKill,VoteCount,UserCount) {
	new strNumber[MAX_NUMBER_LENGTH];
	new Text[MAX_TEXT_LENGTH];
	new strKiPerKill[MAX_DATA_LENGTH];
	new Ratio = KIPERKILL_VOTE_RATIO;
	convert_string(HLKiPerKill,strKiPerKill,MAX_DATA_LENGTH);
 
	if (WinningOption == 1) {
		if (VoteCount >= Ratio*UserCount/100) {
			snprintf(Text, MAX_TEXT_LENGTH, "--:: Changing Ki Per Kill To %s Due To A Vote ::--", strKiPerKill);
			say(Text);
			setstrvar("admin_quiet", "2");
			setstrvar("sv_kiperkill", strKiPerKill);
			setstrvar("admin_quiet", "2");
		} else {
			numtostr(Ratio*UserCount/100,strNumber);
			snprintf(Text, MAX_TEXT_LENGTH, "--:: Ki Per Kill Vote Succeded But Not Enough To Change (Needed %s) ::--", strNumber);
			say(Text);
		}
	} else {
		say("--:: Ki Per Kill Vote Failed ::--");
	}
}
 
public admin_vote_mtimeout(HLCommand,HLData,HLUser,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
	new Text[MAX_TEXT_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(HLUser,User,MAX_NAME_LENGTH);
	getvar("sv_maxtimeout");
	snprintf(Text, MAX_TEXT_LENGTH, "Change Max Timeout To %s Second(s)?", Data);
	log(Text);
	vote(Text,"Yes","No","HandleMTimeoutVote",Data);
	say_command(User,Command,Data);
	snprintf(Text, MAX_TEXT_LENGTH, "[ADMIN] %s Used Admin_Command %s %s.", User, Command, Data);
	writefile(LogFile, Text);
	return PLUGIN_HANDLED;
}
 
public HandleMTimeoutVote(WinningOption,HLMaxTimeout,VoteCount,UserCount) {
	new strNumber[MAX_NUMBER_LENGTH];
	new Text[MAX_TEXT_LENGTH];
	new strMaxTimeout[MAX_DATA_LENGTH];
	new Ratio = KIPERKILL_VOTE_RATIO;
	convert_string(HLMaxTimeout,strMaxTimeout,MAX_DATA_LENGTH);
 
	if (WinningOption == 1) {
		if (VoteCount >= Ratio*UserCount/100) {
			snprintf(Text, MAX_TEXT_LENGTH, "--:: Changing Max Timeout To %s Second(s) Due To A Vote ::--", strMaxTimeout);
			say(Text);
			setstrvar("admin_quiet", "2");
			setstrvar("sv_maxtimeout", strMaxTimeout);
			setstrvar("admin_quiet", "2");
		} else {
			numtostr(Ratio*UserCount/100,strNumber);
			snprintf(Text, MAX_TEXT_LENGTH, "--:: Max Timeout Vote Succeded But Not Enough To Change (Needed %s) ::--", strNumber);
			say(Text);
		}
	} else {
		say("--:: Max Timeout Vote Failed ::--");
	}
}
 
public plugin_init() {
plugin_registerinfo("Mr. Satan's DMZ Votes","--:: Vote For Any Anti-Kill, Ki-Base, Ki Per Kill, & Max Timeout ::--",STRING_VERSION);
 
plugin_registercmd("admin_vote_antikill","admin_vote_antikill",ACCESS_VOTE_ANTIKILL,"admin_vote_antikill: Starts A Vote To ENABLE/DISABLE The KILL Command.");
plugin_registercmd("admin_vote_kibase","admin_vote_kibase",ACCESS_VOTE_KIBASE,"admin_vote_kibase <#>: Starts A Vote To Change The Value Of The KI BASE.");
plugin_registercmd("admin_vote_kikill","admin_vote_kikill",ACCESS_VOTE_KIPERKILL,"admin_vote_kikill <#>: Starts A Vote To Change The Value Of KI PER KILL.");
plugin_registercmd("admin_vote_mtimeout","admin_vote_mtimeout",ACCESS_VOTE_MAXTIMEOUT,"admin_vote_mtimeout <Seconds>: Starts A Vote To Change The Value Of MAX TIMEOUT In SECONDS.");
return PLUGIN_CONTINUE;
}