/* AMX Mod X * Admin Votes Plugin * * by the AMX Mod X Development Team * originally developed by OLO * * This file is part of AMX Mod X. * * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, the author gives permission to * link the code of this program with the Half-Life Game Engine ("HL * Engine") and Modified Game Libraries ("MODs") developed by Valve, * L.L.C ("Valve"). You must obey the GNU General Public License in all * respects for all of the code used other than the HL Engine and MODs * from Valve. If you modify this file, you may extend this exception * to your version of the file, but you are not obligated to do so. If * you do not wish to do so, delete this exception statement from your * version. */ #include #include new g_Answer[128] new g_optionName[4][32] new g_voteCount[4] new g_validMaps new g_yesNoVote new g_coloredMenus new g_voteCaller new g_Execute[256] new g_execLen new bool:g_execResult new Float:g_voteRatio public plugin_init() { register_plugin("Admin Votes",AMXX_VERSION_STR,"AMXX Dev Team") register_dictionary("adminvote.txt") register_dictionary("common.txt") register_menucmd(register_menuid("Change map to "),MENU_KEY_1|MENU_KEY_2,"voteCount") register_menucmd(register_menuid("Choose map: "),MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4,"voteCount") register_menucmd(register_menuid("Kick "),MENU_KEY_1|MENU_KEY_2,"voteCount") register_menucmd(register_menuid("Ban "),MENU_KEY_1|MENU_KEY_2,"voteCount") register_menucmd(register_menuid("Vote: "),MENU_KEY_1|MENU_KEY_2,"voteCount") register_menucmd(register_menuid("The result: "),MENU_KEY_1|MENU_KEY_2,"actionResult") register_concmd("amx_votemap","cmdVoteMap",ADMIN_VOTE," [map] [map] [map]") register_concmd("amx_votekick","cmdVoteKickBan",ADMIN_VOTE,"") register_concmd("amx_voteban","cmdVoteKickBan",ADMIN_VOTE,"") register_concmd("amx_vote","cmdVote",ADMIN_VOTE," ") register_concmd("amx_cancelvote","cmdCancelVote",ADMIN_VOTE,"- cancels last vote") g_coloredMenus = colored_menus() } public cmdCancelVote(id,level,cid) { if (!cmd_access(id,level,cid,0)) return PLUGIN_HANDLED if ( task_exists( 99889988 , 1 ) ) { new authid[32],name[32] get_user_authid(id,authid,31) get_user_name(id,name,31) log_amx("Vote: ^"%s<%d><%s><>^" cancel vote session", name,get_user_userid(id),authid) new players[32],pnum,lTag[16],activity = get_cvar_num("amx_show_activity") get_players(players,pnum,"c") for (new i=0;i g_voteCount[best]) best = a } new votesNum = g_voteCount[0] + g_voteCount[1] + g_voteCount[2] + g_voteCount[3] new iRatio = votesNum ? floatround( g_voteRatio * float( votesNum ) ,floatround_ceil) : 1 new iResult = g_voteCount[best] new players[32],pnum,i get_players(players,pnum,"c") if ( iResult < iRatio ) { new lVotingFailed[64] for (i=0;i get_gametime()) { console_print(id, "%L", id, "ALREADY_VOTING") return PLUGIN_HANDLED } if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) { console_print(id, "%L", id, "VOTING_NOT_ALLOW") return PLUGIN_HANDLED } new argc = read_argc() if (argc > 5) argc = 5 g_validMaps = 0 g_optionName[0][0] = 0 g_optionName[1][0] = 0 g_optionName[2][0] = 0 g_optionName[3][0] = 0 for (new i = 1; i < argc; ++i) { read_argv(i,g_optionName[g_validMaps],31) if (is_map_valid(g_optionName[g_validMaps])) g_validMaps++; } if (g_validMaps == 0) { new lMaps[16] format(lMaps,15,"%L",id,(argc==2)?"MAP_IS":"MAPS_ARE") console_print(id,"%L",id,"GIVEN_NOT_VALID") return PLUGIN_HANDLED } new menu_msg[256] new keys = 0 if (g_validMaps > 1) { keys = MENU_KEY_0 format(menu_msg,255,g_coloredMenus ? "\y%L: \w^n^n" : "%L: ^n^n",LANG_SERVER,"CHOOSE_MAP") new temp[128] for(new a = 0; a < g_validMaps; ++a){ format(temp,127,"%d. %s^n",a+1,g_optionName[a]) add(menu_msg,255,temp) keys |= (1<<%s><>^" vote map (map ^"%s^")", name,get_user_userid(id),authid,g_optionName[0]) else log_amx("Vote: ^"%s<%d><%s><>^" vote maps (map#1 ^"%s^") (map#2 ^"%s^") (map#3 ^"%s^") (map#4 ^"%s^")", name,get_user_userid(id),authid,g_optionName[0],g_optionName[1],g_optionName[2],g_optionName[3]) new lTag[16],activity = get_cvar_num("amx_show_activity") if (activity>0) { new players[32],pnum get_players(players,pnum,"c") for (new i=0;i 1)?"Choose map: ":"Change map to ") set_task(vote_time,"checkVotes" , 99889988 ) g_voteCaller = id console_print(id, "%L", id, "VOTING_STARTED") g_voteCount = { 0,0, 0,0 } return PLUGIN_HANDLED } public cmdVote(id,level,cid) { if (!cmd_access(id,level,cid,4)) return PLUGIN_HANDLED new Float:voting = get_cvar_float("amx_last_voting") if (voting > get_gametime()){ console_print(id, "%L", id, "ALREADY_VOTING") return PLUGIN_HANDLED } if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) { console_print(id, "%L", id, "VOTING_NOT_ALLOW") return PLUGIN_HANDLED } new quest[48] read_argv(1,quest,47) if ((contain(quest,"sv_password")!=-1)||(contain(quest,"rcon_password")!=-1)|| (contain(quest,"kick")!=-1)||(contain(quest,"addip")!=-1)||(contain(quest,"ban")!=-1)){ console_print(id,"%L",id,"VOTING_FORBIDDEN") return PLUGIN_HANDLED } read_argv(2,g_optionName[0],31) read_argv(3,g_optionName[1],31) new authid[32],name[32] get_user_authid(id,authid,31) get_user_name(id,name,31) log_amx("Vote: ^"%s<%d><%s><>^" vote custom (question ^"%s^") (option#1 ^"%s^") (option#2 ^"%s^")", name,get_user_userid(id),authid,quest,g_optionName[0],g_optionName[1]) new activity = get_cvar_num("amx_show_activity") if (activity>0) { new players[32],pnum,lTag[16] get_players(players,pnum,"c") for (new i=0;i get_gametime()){ console_print(id, "%L", id, "ALREADY_VOTING") return PLUGIN_HANDLED } if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) { console_print(id, "%L", id, "VOTING_NOT_ALLOW") return PLUGIN_HANDLED } new cmd[32] read_argv(0,cmd,31) new voteban = equal(cmd,"amx_voteban") new arg[32] read_argv(1,arg,31) new player = cmd_target(id,arg,1) if (!player) return PLUGIN_HANDLED if (voteban && is_user_bot(player)) { new imname[32] get_user_name(player,imname,31) console_print(id,"%L",id,"ACTION_PERFORMED",imname) return PLUGIN_HANDLED } new keys = MENU_KEY_1|MENU_KEY_2 new menu_msg[256],lYes[16],lNo[16],lKickBan[16] format(lYes,15,"%L",LANG_SERVER,"YES") format(lNo,15,"%L",LANG_SERVER,"NO") format(lKickBan,15,"%L",LANG_SERVER,voteban?"BAN":"KICK") ucfirst(lYes) ucfirst(lNo) ucfirst(lKickBan) get_user_name(player,arg,31) format(menu_msg,255,g_coloredMenus ? "\y%s %s?\w^n^n1. %s^n2. %s" : "%s %s?^n^n1. %s^n2. %s", lKickBan, arg, lYes, lNo) g_yesNoVote = 1 if (voteban) get_user_authid(player,g_optionName[0],31) else num_to_str(get_user_userid(player),g_optionName[0],31) new authid[32],name[32] get_user_authid(id,authid,31) get_user_name(id,name,31) log_amx("Vote: ^"%s<%d><%s><>^" vote %s (target ^"%s^")", name,get_user_userid(id),authid,voteban ? "ban" : "kick",arg) new activity = get_cvar_num("amx_show_activity") if (activity>0) { new players[32],pnum,lTag[16] get_players(players,pnum,"c") for (new i=0;i