/* A simple plugin to vote alltalk on or off for fun - created by Argus */ #include <core> #include <console> #include <string> #include <admin> #include <adminlib> #define ALLTALK_VOTE_RATIO 50 #define ACCESS_VOTE_ALLTALK 0 new STRING_VERSION[MAX_DATA_LENGTH] = "2.50.1"; public alltalkon() { new strDummy[10]; vote("Enable AllTalk??", "Yes", "No", "HandlealltalkVote",strDummy); } public HandlealltalkVote(WinningOption,HLData,VoteCount,UserCount) { new Text[MAX_TEXT_LENGTH]; new strNumber[MAX_NUMBER_LENGTH]; new Ratio = ALLTALK_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_alltalk")==1) { centersay("ALLTalk will remain enabled.",18,249,244,0); } else { centersay("Vote successful. AllTalk enabled.",18,249,244,0); exec("sv_alltalk 1"); } } else { if(getvar("sv_alltalk")==1) { centersay("OK Ok...You got your way!^nAllTalk Is OFF",18,63,187,239); exec("sv_alltalk 0"); } else { centersay("Vote over. AllTalk will remain disabled.",18,63,187,239); } } } else { numtostr(Ratio*UserCount/100,strNumber); if(getvar("sv_alltalk")==0) { snprintf(Text, MAX_TEXT_LENGTH, "Vote succeeded, but not enough votes for change (needed %s)^nAllTalk will remain enabled.", strNumber); } else { snprintf(Text, MAX_TEXT_LENGTH, "Vote succeeded, but not enough votes for change (needed %s)^nAllTalk will remain disabled.", strNumber); } centersay(Text,18,63,187,239); } return PLUGIN_CONTINUE; } public admin_vote_alltalk(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 an AllTalk vote"); alltalkon(); return PLUGIN_HANDLED; } public plugin_init() { plugin_registerinfo("AllTalk Plugin","Enables AllTalk voting.",STRING_VERSION); plugin_registercmd("admin_vote_alltalk","admin_vote_alltalk",ACCESS_VOTE_ALLTALK,"admin_vote_alltalk : Starts a vote to enable/disable AllTalk"); return PLUGIN_CONTINUE; }