/* REPUBLIC PLUG-IN BY RUBBER BULLETS SNURTLE1@LYCOS.COM features: public vote ban, vote kick afk's, and vote camper. */ /* Should be steam compatible now. [WING] Black Knight */ #include <core> #include <console> #include <string> #include <admin> #include <adminlib> new STRING_VERSION[MAX_DATA_LENGTH] = "2.50.0"; new strUser[MAX_NAME_LENGTH]; public handlevote(HLCommand,HLData,HLUserName,UserIndex,UserCount) { new Command[MAX_COMMAND_LENGTH]; new Data[MAX_DATA_LENGTH]; new Text[MAX_TEXT_LENGTH]; new Target[MAX_NAME_LENGTH]; new User[MAX_NAME_LENGTH]; new strAuthID[MAX_AUTHID_LENGTH]; new strTime[MAX_NAME_LENGTH]; convert_string(HLCommand,Command,MAX_COMMAND_LENGTH); convert_string(HLData,Data,MAX_DATA_LENGTH); convert_string(HLUserName,strUser,MAX_NAME_LENGTH); strbreak(Data,Target,strTime, MAX_DATA_LENGTH); if (vote_allowed()!=1) { selfmessage( "Vote not allowed at this time."); return PLUGIN_HANDLED; } if (check_user(Target) == 1) { new real_user[MAX_NAME_LENGTH]; get_username(Target,real_user,MAX_NAME_LENGTH); say_command(User,Command,Data); if(check_immunity(real_user)!=0) { selfmessage("That user is above the law."); return PLUGIN_HANDLED; } else { snprintf(Text, MAX_TEXT_LENGTH, "Ban %s for %s minutes?", real_user, strTime); } /*some personal changes this was making my head turn to mush like a calculus problem with tangents, so I made it so I could understand it.*/ if(getvar("sv_lan")==1) { /*not sure what the heck this part is... looks like it only applies to lan people. I dont have lan. Sorry lan guys if this plugin doesn't work right*/ snprintf(Data, MAX_TEXT_LENGTH, "^"%s^" %s", real_user, strTime); /*okay, since this part is confusing, for notes this is the else of target is equal to one, or the target isnt equal to one statment*/ } else { get_userAuthID(real_user,strAuthID); snprintf(Data, MAX_TEXT_LENGTH, "^"%s^" %s", strAuthID, strTime); } /*this statement is in only one if.*/ if(strlen(strTime) == 0) { snprintf(Text, MAX_TEXT_LENGTH, "Cannot permantly ban using public ban votes."); say(Text); return PLUGIN_HANDLED; } /*same with this one*/ if(strlen(strTime) >=10001) { snprintf(Text, MAX_TEXT_LENGTH, "Ban time exceeds 10000 minutes."); say(Text); return PLUGIN_HANDLED; } /*if the plugin has not returned by now, and it's still in this if, the vote will commense, seeing this has spotted an potential problem. Wonder if it ment anything.*/ /*when the vote time is up, it will run the function handlebanvote. See I know how to program fool.*/ vote(Text,"Ban Him","Dont Ban Him","HandleBanVote", Data); } else { /*forgot what this was the else for*/ selfmessage("Unrecognized user name "); selfmessage(Data); } return PLUGIN_HANDLED; } public HandleBanVote(WinningOption,HLUser,VoteCount,UserCount,HLUserName) { new strNumber[MAX_NUMBER_LENGTH]; new Text[MAX_TEXT_LENGTH]; new VoteUser[MAX_DATA_LENGTH]; new strTime[MAX_NAME_LENGTH]; new BanTime = 1; convert_string(HLUser,VoteUser,MAX_DATA_LENGTH); if (UserCount <= 5) { snprintf(Text, MAX_TEXT_LENGTH, "Despite the results, at least six players must be playing."); say(Text); return PLUGIN_HANDLED; } if (WinningOption == 1) { new Ratio = getvar("kick_ratio"); /*self explanitory. Gotta at least be equal to the vote ratio. Recommended your vote ratio be greater than 50 percent, but not too high*/ if (VoteCount >= Ratio*UserCount/100) { /*breaks the voteuser thingy wingy into voteuser and time.*/ strbreak(VoteUser,VoteUser,strTime, MAX_DATA_LENGTH); /*one statement if. Doesn't need squirrelly brackets*/ if(strlen(strTime) == 0) BanTime = strtonum(strTime); /*says the statement on the screen as an admin say*/ snprintf(Text, MAX_TEXT_LENGTH, "%s was banned for %s minutes due to a vote.", VoteUser, strTime); say(Text); /*reuses the text variable and tells the suckaflick he's been banned like a mofo*/ snprintf(Text, MAX_TEXT_LENGTH, "You have been banned for %s minutes due to a vote.", strTime); message(VoteUser,Text); ban(VoteUser,BanTime); kick(VoteUser); /*kicking the user is important otherwise he'll still diddly dattle around until he finally decides to leave*/ } else { /*the almighty else statement. If it isn't one it's the other. Right?*/ numtostr(Ratio*UserCount/100,strNumber); snprintf(Text, MAX_TEXT_LENGTH, "Ban vote succeeded, but not enough votes to Ban %s (needed %s)", VoteUser ,strNumber); say(Text); /*We've seen that text before. But not the stuff below.*/ /*here it gets nasty on the user because he could be some 8 year old punk*/ /*I changed this from a self message to a personal message because I'm not sure if perhaps everyone gets this message*/ /*it is after all in it's own function*/ snprintf(Text, MAX_TEXT_LENGTH, "You have been banned for 15 minutes due to ban vote failure. Only request a ban vote if you are serious."); message(strUser,Text); ban(strUser,15); kick(strUser); /*kick kick kick*/ } } else { /*changed the following line from just a plain say to command to the complicated snprintf then say command to, again, because I know it works*/ snprintf(Text, MAX_TEXT_LENGTH, "The Ban Vote Failed. %s was auto-kicked in case he was abusing the command.", strUser); say(Text); /*this is changed again from the selfmessage*/ snprintf(Text, MAX_TEXT_LENGTH, "You have been banned for 15 minutes due to ban vote failure. Only request a ban vote if you are serious."); message(strUser,Text); ban(strUser,15); kick(strUser); /*most certainly he should be kicked*/ } return PLUGIN_HANDLED; } public kick_afk(HLCommand,HLData,HLUserName,UserIndex,UserCount) { new Command[MAX_COMMAND_LENGTH]; new Data[MAX_DATA_LENGTH]; new Text[MAX_TEXT_LENGTH]; new User[MAX_NAME_LENGTH]; new strAuthID[MAX_AUTHID_LENGTH]; convert_string(HLCommand,Command,MAX_COMMAND_LENGTH); convert_string(HLData,Data,MAX_DATA_LENGTH); convert_string(HLUserName,strUser,MAX_NAME_LENGTH); /*this is basicly just the admin_vote_kick function with some slight changes.*/ if (vote_allowed()!=1) { selfmessage( "Vote not allowed at this time."); return PLUGIN_HANDLED; } 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) { /*changed this so that the immune player knows he was targeted*/ snprintf(Text, MAX_TEXT_LENGTH, "I doubt %s is afk. If he is... wake up!!!", real_user); say(Text); return PLUGIN_HANDLED; /*added the return here to avoid any problems... unless something gay happens*/ } else { snprintf(Text, MAX_TEXT_LENGTH, "Is %s afk?", real_user); if(getvar("sv_lan")==1) { vote(Text,"Yes","No","afkkickvote",real_user); } else { get_userAuthID(real_user,strAuthID); vote(Text,"Yes","No","afkkickvote",strAuthID); } } } else { selfmessage("Unrecognized user name "); selfmessage(Data); } return PLUGIN_HANDLED; } /* Handle a kick vote's results. */ public afkkickvote(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 (UserCount <= 5) { snprintf(Text, MAX_TEXT_LENGTH, "Despite the results, at least six players must be playing."); say(Text); return PLUGIN_HANDLED; } if (WinningOption == 1) { new Ratio = getvar("kick_ratio"); if (VoteCount >= Ratio*UserCount/100) { snprintf(Text, MAX_TEXT_LENGTH, "%s was kicked due to a vote.", VoteUser); say(Text); message(VoteUser,"You have been kicked for being afk due to a vote."); kick(VoteUser); } else { numtostr(Ratio*UserCount/100,strNumber); snprintf(Text, MAX_TEXT_LENGTH, "Kick vote succeeded, but not enough votes for kick (needed %s)",strNumber); say(Text); snprintf(Text, MAX_TEXT_LENGTH, "Only request an afk vote if you know everyone knows he's afk!!! Your banned for 10 minutes."); message(strUser,Text); ban(strUser,10); kick(strUser); } } else { say("AFK vote failed."); snprintf(Text, MAX_TEXT_LENGTH, "%s was banned for 10 minutes because his kick vote failed.",strUser); say(Text); snprintf(Text, MAX_TEXT_LENGTH, "Only request an afk vote if you know everyone knows he's afk!!! Your banned for 10 minutes."); message(strUser,Text); ban(strUser,10); kick(strUser); } return PLUGIN_HANDLED; } public vote_tent(HLCommand,HLData,HLUserName,UserIndex,UserCount) { new Command[MAX_COMMAND_LENGTH]; new Data[MAX_DATA_LENGTH]; new Text[MAX_TEXT_LENGTH]; new User[MAX_NAME_LENGTH]; new strAuthID[MAX_AUTHID_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,strUser,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, "Well, it IS his server...", real_user); say(Text); return PLUGIN_HANDLED; } else { snprintf(Text, MAX_TEXT_LENGTH, "Is %s boring us?", real_user); if(getvar("sv_lan")==1) { vote(Text,"Yes","No","camperslayvote",real_user); } else { get_userAuthID(real_user,strAuthID); vote(Text,"Yes","No","camperslayvote",strAuthID); } } } else { selfmessage("Unrecognized user name "); selfmessage(Data); } return PLUGIN_HANDLED; } /* Handle a kick vote's results. */ public camperslayvote(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 (UserCount <= 5) { snprintf(Text, MAX_TEXT_LENGTH, "Despite the results, at least six players must be playing."); say(Text); return PLUGIN_HANDLED; } if (WinningOption == 1) { new Ratio = getvar("kick_ratio"); if (VoteCount >= Ratio*UserCount/100) { snprintf(Text, MAX_TEXT_LENGTH, "%s was slayed due to a vote.", VoteUser); say(Text); message(VoteUser,"You have been declared a camper due to a vote."); slay(VoteUser); } else { numtostr(Ratio*UserCount/100,strNumber); snprintf(Text, MAX_TEXT_LENGTH, "Camper vote succeeded, but not enough votes for killing (needed %s)",strNumber); say(Text); snprintf(Text, MAX_TEXT_LENGTH, "Not enough people agree with you. Your banned for 5 minutes."); message(strUser,Text); ban(strUser,5); kick(strUser); } } else { say("AFK vote failed."); snprintf(Text, MAX_TEXT_LENGTH, "%s has been kicked because he doesn't understand an aspect of the game.",strUser); say(Text); snprintf(Text, MAX_TEXT_LENGTH, "Not enough people agree with you. Your banned for 5 minutes."); message(strUser,Text); kick(strUser); ban(strUser,5); } return PLUGIN_HANDLED; } public plugin_init() { plugin_registerinfo("Admin Ban Vote Plugin","Doh!",STRING_VERSION); plugin_registercmd("vote_ban","handlevote",ACCESS_ALL,"vote_ban <name|uniqueid> <time> : Starts a vote to ban target for x minutes."); plugin_registercmd("vote_afk","kick_afk",ACCESS_ALL,"vote_afk <name|uniqueid> : Starts a vote to kick target."); plugin_registercmd("vote_camper","vote_tent",ACCESS_ALL,"vote_camper <name|uniqueid> : Starts a vote to slay a target."); return PLUGIN_CONTINUE; }