/***************************************************\ * ADMIN_VOTE_BAN * * * * A plugin written out of necessity by * * the Knights of Solaris Clan to counter spammers * * when admins are not present. * * * * Allows the players to vote to ban a spammer with * * a 30 minute cap on it, preventing the spammer * * from returning; a better method than * * admin_vote_kick, since the spammer can just * * return after being kicked. * * * * You can change the amount of time to ban a voted * * player by by scrolling down to where the line is * * commented. Be sure to change every mention of * * thirty minutes to match the time you set to ban * * players by. * * * * Written by, * * John Cardenas, AKA 0==|==KoS==> Solarian Knight * * Clan Leader * \***************************************************/ #include <core> #include <string> #include <admin> #include <adminlib> #define ACCESS_VOTE_BAN 1 new STRING_VERSION[MAX_DATA_LENGTH] = "1.0"; public plugin_init() { plugin_registerinfo("Temporary vote ban plugin","Allows to vote ban a player for 30 minutes.",STRING_VERSION); plugin_registercmd("admin_vote_ban","admin_vote_ban",ACCESS_VOTE_BAN,"admin_vote_ban <target>: Starts a vote to ban target for thirty minutes."); return PLUGIN_CONTINUE; } public admin_vote_ban(HLCommand,HLData,HLUserName,UserIndex) { new Command[MAX_COMMAND_LENGTH]; new Data[MAX_DATA_LENGTH]; new Text[MAX_TEXT_LENGTH]; new User[MAX_NAME_LENGTH]; new WONID; new strWONID[MAX_NUMBER_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); if (check_user(Data) == 1) { new real_user[MAX_NAME_LENGTH]; get_username(Data,real_user,MAX_NAME_LENGTH); say_command(User,Command,Data); if(check_immunity(real_user)!=0) { snprintf(Text, MAX_TEXT_LENGTH, "Laf. You can't ban %s, you silly bear.", real_user); messageex(User, Text, print_chat); } else { snprintf(Text, MAX_TEXT_LENGTH, "Thirty minute ban on %s?", real_user); if(getvar("sv_lan")==1) { vote(Text,"Yes","No","HandleKickVote",real_user); } else { get_userWONID(real_user,WONID); numtostr(WONID,strWONID); vote(Text,"Yes","No","HandleBanVote",strWONID); } } } else { selfmessage("Unrecognized user name "); selfmessage(Data); } return PLUGIN_HANDLED; } public HandleBanVote(WinningOption,HLUser,VoteCount,UserCount) { new strNumber[MAX_NUMBER_LENGTH]; new Text[MAX_TEXT_LENGTH]; new VoteUser[MAX_DATA_LENGTH]; convert_string(HLUser,VoteUser,MAX_DATA_LENGTH); if (WinningOption == 1) { new Ratio = getvar("kick_ratio"); if (VoteCount >= Ratio*UserCount/100) { snprintf(Text, MAX_TEXT_LENGTH, "%s was banned for thirty minutes due to a vote.", VoteUser); say(Text); message(VoteUser,"You have been banned for thirty minutes due to a vote."); ///////////////////////////////////////////EDIT TIME HERE AFTER VoteUser ban(VoteUser,30); } else { numtostr(Ratio*UserCount/100,strNumber); snprintf(Text, MAX_TEXT_LENGTH, "Ban vote succeeded, but not enough votes for ban (needed %s)",strNumber); say(Text); } } else { say("Ban vote failed."); } }