/* This plugin is one of many disable class plugins, this specific one lets you vote for disabling HWguys. */ /* plugin_Dale_disableclass.sma by Dale */ #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 MX_VOTE_RATIO 40 /* Do not change "#define auto_mx_vote 0" */ #define AUTO_MX_VOTE 0 #define ACCESS_VOTE_MX 1 #define ACCESS_FUN 8192 new STRING_VERSION[MAX_DATA_LENGTH] = "2.50.0"; public MXVote() { new strDummy[10]; if(vote_allowed()!=1){ selfmessage("disable classes not available at this time."); return PLUGIN_HANDLED; } if (getvar("admin_fun_mode")==0) { selfmessage("Class disabling can only work during fun mode."); return PLUGIN_HANDLED; } vote("disable HWguy?", "YES PLEASE!!!!!", "No way HWguys rule!!!", "HandleMXVote",strDummy); return PLUGIN_HANDLED; } public HandleMXVote(WinningOption,HLData,VoteCount,UserCount) { new Text[MAX_TEXT_LENGTH]; new strNumber[MAX_NUMBER_LENGTH]; new Ratio = MX_VOTE_RATIO; new strData[MAX_DATA_LENGTH]; convert_string(HLData, strData,MAX_DATA_LENGTH); if (VoteCount >= Ratio*UserCount/100) { if (WinningOption==1) { if(getvar("cr_hwguy")==0) { centersay("Vote over HWguys can still stay.",18,249,244,0); } else { centersay("Vote successful, HWguys can stay",18,249,244,0); exec("cr_hwguy 0"); } } else { if(getvar("cr_hwguy")==-1) { centersay("Vote over HWguys are enabled again.",18,63,187,239); exec("cr_hwguy 1"); } else { centersay("Vote over, HWguys are still available.",18,63,187,239); } } } else { numtostr(Ratio*UserCount/100,strNumber); if(getvar("cr_hwguy")==-1) { snprintf(Text, MAX_TEXT_LENGTH, "HWguy allowance did win but, not enough votes for change (needed %s)^nHWguys are still disabled.", strNumber); } else { snprintf(Text, MAX_TEXT_LENGTH, "HWguy disabling did win but, not enough votes for change (needed %s)^nHwguys will still be enabled.", strNumber); } centersay(Text,18,63,187,239); } } public admin_vote_hwguy(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); MXVote(); 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, "vote_HWguy")!=-1) { MXVote(); return PLUGIN_CONTINUE; } if (strcasestr(Data, "HWguy")!=-1) { Match = TRUE; } if (Match==TRUE) { if (getvar("cr_hwguy") == -1){ centersay ("HWguys are disabled!^n To change say vote_HWguy",7,0,255,0); } else { centersay ("HWguys are enabled!^n To change say vote_HWguy. ",7,0,255,0); } } return PLUGIN_CONTINUE; } public admin_HWguy(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); if(check_param(Data)==1) { execute_command(User,Command,"cr_hwguy","-1"); centersay ("HWguys are disabled!^n To change say vote_HWguy!",7,0,255,0); } else { execute_command(User,Command,"cr_hwguy","1"); centersay ("HWguys are available. ^n To change say vote_HWguy. ",7,0,255,0); } MXVote(); return PLUGIN_HANDLED; } public plugin_init() { plugin_registerinfo("Disable Classes plugin","Enables classes to be voted on/off.",STRING_VERSION); plugin_registercmd("admin_vote_HWguy","admin_vote_HWguy",ACCESS_VOTE_MX); plugin_registercmd("admin_HWguy","admin_HWguy",ACCESS_FUN,"admin_HWguy <#> 1 disables HWguyrs, 0 enables HWguys."); plugin_registercmd("say","HandleSay",ACCESS_ALL); plugin_registerhelp("say",ACCESS_ALL,"say HWguy: Will say if HWguys are available, if clients say vote_HWguy will start vote."); plugin_registerhelp("say",ACCESS_ALL,"say vote_HWguy: Will start HWguy vote."); #if AUTO_MX_VOTE==1 set_timer("MXVote",30,1); #endif return PLUGIN_CONTINUE; }