/* * VOTE ROUNDRESTART PLUGIN by VALHERU ************************************** * description: * * with this plugin, players can cast a vote to restart the round (useful e.g. for clan matches). * ************************************************************************************************* * command: admin_vote_round * ************************************************************************************************* * credits: this plugin is based on the sniperwar plugin by Bryan Clay * * */ #include <core> #include <console> #include <string> #include <admin> #include <adminlib> #define RESTART_VOTE_RATIO 60 #define ACCESS_VOTE_RESTART 0 new STRING_VERSION[MAX_DATA_LENGTH] = "1.0"; public RoundRestartVote() { new strDummy[10]; vote("Restart round?","Yes", "No", "HandleRRVote",strDummy); } public HandleRRVote(WinningOption,HLData,VoteCount,UserCount) { new Ratio = RESTART_VOTE_RATIO; new strData[MAX_DATA_LENGTH]; new Current[MAX_DATA_LENGTH]; convert_string(HLData, strData,MAX_DATA_LENGTH); currentmap(Current,MAX_NAME_LENGTH); if (VoteCount >= Ratio*UserCount/100) { if (WinningOption==1) { typesay("Vote passed.^nRound will restart now.",15,249,244,0); exec("sv_restartround 15"); } else { typesay("Vote did not pass.^nRound will not be restarted.",15,249,244,0); } } else { typesay("Vote succeded, but not enough votes.^nRound will not be restarted.",15,249,244,0); } return PLUGIN_CONTINUE; } public admin_vote_round(HLCommand,HLData,HLUserName,UserIndex) { new Command[MAX_COMMAND_LENGTH]; new Data[MAX_DATA_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); selfmessage("You started a vote to restart the round."); RoundRestartVote(); return PLUGIN_HANDLED; } public plugin_init() { plugin_registerinfo("Vote roundrestart plugin","Enables voting for a round restart.",STRING_VERSION); plugin_registercmd("admin_vote_round","admin_vote_round",ACCESS_VOTE_RESTART,"admin_vote_round : Starts a vote to restart the round."); return PLUGIN_CONTINUE; }