/* Partially coded by PabloHoney. Used to mute those really annoying VoiceComm abusers. Large amounts of code stolen from plugin_retribution, and some others. */ #include <core> #include <console> #include <string> #include <admin> #include <adminlib> #define ACCESS_MUTE 2048 #define ACCESS_VOTE_MUTE 1 new STRING_VERSION[MAX_DATA_LENGTH] = "2.50.00"; public admin_mute(HLCommand,HLData,HLUserName,UserIndex) { new Command[MAX_COMMAND_LENGTH]; new Data[MAX_DATA_LENGTH]; new TargetName[MAX_NAME_LENGTH]; new Text[MAX_TEXT_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_user(Data) == 1) { get_username(Data,TargetName,MAX_NAME_LENGTH); if(check_immunity(TargetName)!=0) { snprintf(Text, MAX_TEXT_LENGTH, "Laf. You can't mute %s, you silly bear.", TargetName); say(Text); } else { execclient(TargetName, "voice_enable 0"); messageex(TargetName, "[ADMIN] You have been muted, so NAH!", print_chat); selfmessage( "Mute Succeeded for player: "); selfmessage(TargetName); } } else { selfmessage("Unrecognized player: "); selfmessage(Data); } return PLUGIN_HANDLED; } public admin_unmute(HLCommand,HLData,HLUserName,UserIndex) { new Command[MAX_COMMAND_LENGTH]; new Data[MAX_DATA_LENGTH]; new TargetName[MAX_NAME_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_user(Data) == 1) { get_username(Data,TargetName,MAX_NAME_LENGTH); execclient(TargetName, "voice_enable 1"); messageex(TargetName, "[ADMIN] You have been UNmuted. Restart CS to regain Voice Comm.", print_chat); selfmessage( "UNMute Succeeded for player: "); selfmessage(TargetName); } else { selfmessage("Unrecognized player: "); selfmessage(Data); } return PLUGIN_HANDLED; } public admin_vote_mute(HLCommand,HLData,HLUserName,UserIndex) { new Command[MAX_COMMAND_LENGTH]; new Data[MAX_DATA_LENGTH]; new Text[MAX_TEXT_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); if (check_user(Data) == 1) { new real_user[MAX_NAME_LENGTH]; get_username(Data,real_user,MAX_NAME_LENGTH); if(check_immunity(real_user)!=0) { snprintf(Text, MAX_TEXT_LENGTH, "You cant vote_mute %s, you silly bear.", real_user ); say(Text); } else { snprintf(Text, MAX_TEXT_LENGTH, "Mute %s ?", real_user); vote(Text,"Yes","No","HandleMuteVote", real_user); } } else { selfmessage("Unrecognized user name "); selfmessage(Data); } return PLUGIN_HANDLED; } public HandleMuteVote(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 muted due to a vote.", VoteUser); say(Text); snprintf(Text, MAX_TEXT_LENGTH, "You have been muted due to a vote."); message(VoteUser,Text); execclient(VoteUser,"voice_enable 0"); } else { numtostr(Ratio*UserCount/100,strNumber); snprintf(Text, MAX_TEXT_LENGTH, "Mute vote succeeded, but not enough votes to mute %s (needed %s)", VoteUser ,strNumber); say(Text); } } else { say("The Mute Vote Was A Failiure."); } } public plugin_init() { plugin_registerinfo("Admin Muting Plugin","Vote to Mute a person's voice comm, or just mute it.",STRING_VERSION); plugin_registercmd("admin_vote_mute","admin_vote_mute",ACCESS_VOTE_MUTE,"admin_vote_mute <name|wonid> : Starts a vote to mute target."); plugin_registercmd("admin_mute","admin_mute",ACCESS_MUTE,"admin_mute <name|wonid> : Mutes a players Voice Comm."); plugin_registercmd("admin_unmute","admin_unmute",ACCESS_MUTE,"admin_unmute <name|wonid> : Unmutes a muted player."); return PLUGIN_CONTINUE; }