/* This plugin enables clients to vote for the value of the cvar "cdrequired" * Using code from friendly fire vote plugin from Kleen13. */ /* $Id: plugin_vote_cd.sma,v 1.0 2002/23/02 geniusly email: easystats@yahoo.com$ */ #include <core> #include <console> #include <string> #include <admin> #include <adminlib> /* Change this to whatever ratio of players need to vote for a setting to change it. */ #define CD_VOTE_RATIO 50 /* Change to 1 to have a CD vote start 5 minutes into a map */ #define AUTO_CD_VOTE 1 #define ACCESS_VOTE_CD 1 new STRING_VERSION[MAX_DATA_LENGTH] = "2.50.0"; public CDVote() { new strDummy[10]; vote("Make Cheating-Death required/optional ?", "Required", "Optional", "HandleCDVote",strDummy); } public HandleCDVote(WinningOption,HLData,VoteCount,UserCount) { new Text[MAX_TEXT_LENGTH]; new strNumber[MAX_NUMBER_LENGTH]; new Ratio = CD_VOTE_RATIO; new strData[MAX_DATA_LENGTH]; convert_string(HLData, strData,MAX_DATA_LENGTH); if (VoteCount >= Ratio*UserCount/100) { if (WinningOption==1) { if(getvar("cdrequired")==1) { centersay("Cheating-Death will remain required",18,249,244,0); } else { centersay("Cheating-Death is now required",18,249,244,0); exec("cdrequired 1"); } } else { if(getvar("cdrequired")==1) { centersay("Cheating Death is now optional",18,63,187,239); exec("cdrequired 0"); } else { centersay("Cheating Death will remain optional",18,63,187,239); } } } else { numtostr(Ratio*UserCount/100,strNumber); if(getvar("cdrequired")==1) { snprintf(Text, MAX_TEXT_LENGTH, "Vote succeeded, but not enough votes for change (needed %s)^nCheating-Death will remain required", strNumber); } else { snprintf(Text, MAX_TEXT_LENGTH, "Vote succeeded, but not enough votes for change (needed %s)^nCheating-Death will remain optional", strNumber); } centersay(Text,18,63,187,239); } } public admin_vote_cd(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); CDVote(); return PLUGIN_HANDLED; } 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, "cd")!=-1) { Match = TRUE; } else if (strcasestr(Data, "cheating")!=-1) { Match = TRUE; } else if (strcasestr(Data, "c-d")!=-1) { Match = TRUE; } if (Match==TRUE) { if (getvar("cdrequired") == 1){ centersay ("Cheating-Death is required. To change say vote_cd",7,0,255,0); } else { centersay ("Cheating-Death is optional. To change say vote_cd",7,0,255,0); } } if (strcasestr(Data, "vote_cd")!=-1) { CDVote(); } return PLUGIN_CONTINUE; } public plugin_init() { plugin_registerinfo("CD vote Plugin","Enables CDreq cvar votes and auto-responses.",STRING_VERSION); plugin_registercmd("admin_vote_cd","admin_vote_cd",ACCESS_VOTE_CD,"admin_vote_cd : Starts a vote to make CD required/optional"); plugin_registercmd("say","HandleSay",ACCESS_ALL); plugin_registerhelp("say",ACCESS_ALL,"say cd, cheating, c-d: Will give CD cvar status."); #if AUTO_CD_VOTE==1 if (vote_allowed()!=1) { selfmessage( "Vote not allowed at this time."); return PLUGIN_HANDLED; } set_timer("CDVote",300,2); #endif return PLUGIN_CONTINUE; }