From 73b365e9526bfe5e145541f6567a24d817fdecbc Mon Sep 17 00:00:00 2001 From: connorr Date: Sat, 24 Aug 2013 00:55:21 +0200 Subject: [PATCH] Fix two player transfer issues in Players Menu plugin (bug 5850, r=arkshine) Former-commit-id: 16f9e669369e6d2b5be6a39ba56b3c8f07b5a5f2 --- plugins/lang/plmenu.txt | 22 ++++++ plugins/plmenu.sma | 162 +++++++++++++++++++++++++++++++++++----- 2 files changed, 164 insertions(+), 20 deletions(-) diff --git a/plugins/lang/plmenu.txt b/plugins/lang/plmenu.txt index 5d51b249..dee9672b 100755 --- a/plugins/lang/plmenu.txt +++ b/plugins/lang/plmenu.txt @@ -14,6 +14,7 @@ TEAM_MENU = Team Menu TRANSF_TO = Transfer to %s CL_CMD_MENU = Client Cmds Menu NO_CMDS = No cmds available +CANT_PERF_PLAYER = That action can't be performed on player "%s" [de] ADMIN_BAN_1 = ADMIN: bannt %s @@ -31,6 +32,7 @@ TEAM_MENU = Menu > Team TRANSF_TO = zu den %s geschoben CL_CMD_MENU = Menu > Spielerbefehle NO_CMDS = keine Befehle verfuegbar +CANT_PERF_PLAYER = Diese Aktion kann nicht am spieler "%s" ausgefuehrt werden. [sr] ADMIN_BAN_1 = ADMIN: ban %s @@ -48,6 +50,7 @@ TEAM_MENU = Tim Meni TRANSF_TO = Transfer u %s CL_CMD_MENU = Klijent Komande Meni NO_CMDS = Nema dostupnih komandi +CANT_PERF_PLAYER = Komanda ne moze biti izvrsena na igrac "%s" [tr] ADMIN_BAN_1 = ADMIN: ban %s @@ -65,6 +68,7 @@ TEAM_MENU = Takim menu TRANSF_TO = %s takima goc CL_CMD_MENU = Oyuncu Emir Menusu NO_CMDS = Emir mevcud degildir +CANT_PERF_PLAYER = Oyuncu uzerinde bunu yapamazsiniz "%s" [fr] ADMIN_BAN_1 = ADMIN: banni %s @@ -82,6 +86,7 @@ TEAM_MENU = Menu Equipe TRANSF_TO = Transferer en %s CL_CMD_MENU = Menu Cmds Client NO_CMDS = Aucune commande disponible +CANT_PERF_PLAYER = Cette action ne peut pas etre faite sur le joueur "%s" [sv] ADMIN_BAN_1 = ADMIN: bannlys %s @@ -99,6 +104,7 @@ TEAM_MENU = Lagmeny TRANSF_TO = Skicka till %s CL_CMD_MENU = Klientkommandomeny NO_CMDS = Det finns inga kommandon +CANT_PERF_PLAYER = Den handlingen kan inte utf'o'ras pa spelare "%s" [da] ADMIN_BAN_1 = ADMIN: ban %s @@ -116,6 +122,7 @@ TEAM_MENU = Hold Menu TRANSF_TO = Overflyt til %s CL_CMD_MENU = Klient Kommando Menu NO_CMDS = Ingen kommandoer til raadighed +CANT_PERF_PLAYER = Den handling kan ikke udfoeres paa spiller "%s" [pl] ADMIN_BAN_1 = Admin zbanowal %s @@ -133,6 +140,7 @@ TEAM_MENU = Menu druzyny TRANSF_TO = Przejdz do %s CL_CMD_MENU = menu komend klienta NO_CMDS = Nie ma zadnych komend +CANT_PERF_PLAYER = Nie mozesz tego wykonac na gracz "%s" [nl] ADMIN_BAN_1 = ADMIN: ban %s @@ -150,6 +158,7 @@ TEAM_MENU = Teammenu TRANSF_TO = Zet over naar %s CL_CMD_MENU = Gebruikerscommandomenu NO_CMDS = Geen cmds beschikbaar +CANT_PERF_PLAYER = Die actie kan niet worden uitgevoerd op speler "%s" [es] ADMIN_BAN_1 = ADMIN: %s baneado @@ -167,6 +176,7 @@ TEAM_MENU = Menu de Equipos TRANSF_TO = Transferir a los %s CL_CMD_MENU = Menu de Comandos de Cliente NO_CMDS = No hay comandos disponibles +CANT_PERF_PLAYER = Esta accion no se puede aplicar a jugador "%s" [bp] ADMIN_BAN_1 = ADMIN: baniu %s @@ -184,6 +194,7 @@ TEAM_MENU = Menu de Controle de Time TRANSF_TO = Transferir para %s CL_CMD_MENU = Menu de Comandos no Cliente NO_CMDS = Sem comandos disponiveis +CANT_PERF_PLAYER = Aquela acao nao pode ser executada com jogador "%s" [cz] ADMIN_BAN_1 = ADMIN: zabanoval %s @@ -201,6 +212,7 @@ TEAM_MENU = Menu Tymu TRANSF_TO = Premistit k %s CL_CMD_MENU = Menu klientskych prikazu NO_CMDS = Zadny cmds +CANT_PERF_PLAYER = Tato operace nelze provest na hrac "%s" [fi] ADMIN_BAN_1 = ADMIN: bannasi %s @@ -218,6 +230,7 @@ TEAM_MENU = Joukkuevalikko TRANSF_TO = Siirra %s.ksi CL_CMD_MENU = Clientkomentovalikko NO_CMDS = Ei komentoja kaytettavissa +CANT_PERF_PLAYER = Tuota toimintoa ei voida suorittaa pelaaja "%s" [ls] ADMIN_BAN_1 = ADMIN: b4nz0|2 %s @@ -235,6 +248,7 @@ TEAM_MENU = T34m M3nu TRANSF_TO = Tr4nsf3r t0 %s CL_CMD_MENU = (li3nt (mds M3nu NO_CMDS = |\|0 cmds 4v4il4bl3 +CANT_PERF_PLAYER = "%s" iz 4 l33t p|4y3r! [bg] ADMIN_BAN_1 = ADMINISTRATOR: banna %s @@ -252,6 +266,7 @@ TEAM_MENU = Otborno Menu TRANSF_TO = Transferirai kam %s CL_CMD_MENU = Klient Comandno Menu NO_CMDS = Nqma nikakvi pozvoleni comandi +CANT_PERF_PLAYER = Tazi comanda nemoje da se izpolzva na igra4 "%s" [ro] ADMIN_BAN_1 = ADMIN: ban %s @@ -269,6 +284,7 @@ TEAM_MENU = Menu Echipe TRANSF_TO = Transfera la %s CL_CMD_MENU = Menu Comenzi Jucator NO_CMDS = Nici o comanda valabila +CANT_PERF_PLAYER = Aceasta comanda nu poate fi executata pe jucatorul "%s" [hu] ADMIN_BAN_1 = ADMIN: %s banolva @@ -286,6 +302,7 @@ TEAM_MENU = CSapat Menu TRANSF_TO = Atallitva %s-nek CL_CMD_MENU = Client Cmds Menu NO_CMDS = Nincs elerheto parancs +CANT_PERF_PLAYER = Ezt az akciot nem hajthatod vegre "%s"-on jatekos [lt] ADMIN_BAN_1 = ADMINAS: isbanino %s @@ -303,6 +320,7 @@ TEAM_MENU = Komandos meniu TRANSF_TO = Issiusti i %s CL_CMD_MENU = Klientu CMD meniu NO_CMDS = Nera galimu CMD +CANT_PERF_PLAYER = Sio veiksmo negalima naudoti ant jaidejui "%s" [sk] ADMIN_BAN_1 = ADMIN: zabanoval %s @@ -320,6 +338,7 @@ TEAM_MENU = MENU: Tym TRANSF_TO = Premiestnit k %s CL_CMD_MENU = MENU: klientske prikazy NO_CMDS = Ziadny cmds +CANT_PERF_PLAYER = Tato operacia nejde previest na hrac "%s" [mk] ADMIN_BAN_1 = ADMIN: ban %s @@ -337,6 +356,7 @@ TEAM_MENU = Meni za timot TRANSF_TO = Transfer vo %s CL_CMD_MENU = Meni so komandi za klientite NO_CMDS = Nema dostapni komandi +CANT_PERF_PLAYER = Komandata ne moze da bide izvrsena na igrac "%s" [hr] ADMIN_BAN_1 = ADMIN: banao %s @@ -354,6 +374,7 @@ TEAM_MENU = Izbornik timova TRANSF_TO = Transfer u %s CL_CMD_MENU = Izbornik naredbi klijenta NO_CMDS = Nema dostupnih naredbi +CANT_PERF_PLAYER = That action can't be performed on player "%s" [bs] ADMIN_BAN_1 = ADMIN: ban %s @@ -371,4 +392,5 @@ TEAM_MENU = Tim Meni TRANSF_TO = Transfer u %s CL_CMD_MENU = Klijent Komande Meni NO_CMDS = Nema dostupnih komand +CANT_PERF_PLAYER = That action can't be performed on player "%s" diff --git a/plugins/plmenu.sma b/plugins/plmenu.sma index b8d1f57e..6aa90280 100755 --- a/plugins/plmenu.sma +++ b/plugins/plmenu.sma @@ -38,6 +38,7 @@ /** skip autoloading since it's optional */ #define AMXMODX_NOAUTOLOAD #include +#include new g_menuPosition[33] new g_menuPlayers[33][32] @@ -57,6 +58,7 @@ new g_clcmdNum new g_coloredMenus new g_cstrike = 0 +new g_fakemeta = 0, m_iMenu, m_bTeamChanged, Menu_ChooseAppearance new Array:g_bantimes; new Array:g_slapsettings; @@ -74,9 +76,14 @@ new g_CSTeamNumbers[3][] = { new g_CSTeamiNumbers[3] = { 1, 2, - 6 + 3 } +new g_CSPlayerCanSwitchFromSpec[33] +new g_transferingAdmin + +new allow_spectators, mp_limitteams + new p_amx_tempban_maxtime; new Trie:g_tempBans; @@ -135,8 +142,26 @@ public plugin_init() format(clcmds_ini_file, 63, "%s/clcmds.ini", clcmds_ini_file) load_settings(clcmds_ini_file) - if (module_exists("cstrike")) + if (LibraryExists("cstrike", LibType_Library)) g_cstrike = 1 + if (LibraryExists("fakemeta", LibType_Library)) + { + g_fakemeta = 1 + m_iMenu = 205 + m_bTeamChanged = 501 + Menu_ChooseAppearance = 3 + } + + new modname[9] + get_modname(modname, charsmax(modname)) + if( equal(modname, "cstrike") || equal(modname, "czero") ) + { + register_event("TeamInfo", "Event_TeamInfo", "a", "2=TERRORIST", "2=CT") + register_event("TextMsg", "Event_TextMsg", "b", "1=4", "2=#Only_1_Team_Change") + } + + allow_spectators = get_cvar_pointer("allow_spectators") + mp_limitteams = get_cvar_pointer("mp_limitteams") } public plugin_cfg() @@ -207,7 +232,7 @@ public plmenu_setslapdmg() } public module_filter(const module[]) { - if (equali(module, "cstrike")) + if (equali(module, "cstrike") || equali(module, "fakemeta")) return PLUGIN_HANDLED return PLUGIN_CONTINUE @@ -660,13 +685,37 @@ public cmdKickMenu(id, level, cid) /* Team menu */ +public client_putinserver(id) +{ + g_CSPlayerCanSwitchFromSpec[id] = false +} + +public Event_TeamInfo() +{ + new id = read_data(1) + if ( is_user_connected(id) ) + { + g_CSPlayerCanSwitchFromSpec[id] = true + } +} + +public Event_TextMsg( id ) // #Only_1_Team_Change +{ + if( g_transferingAdmin && is_user_connected(id) && (id == g_transferingAdmin || is_user_connected(g_transferingAdmin)) ) + { + new name[32] + get_user_name(id, name, charsmax(name)) + client_print(g_transferingAdmin, print_chat, "%L", g_transferingAdmin, "CANT_PERF_CLIENT", name); + } +} + public actionTeamMenu(id, key) { switch (key) { case 7: { - g_menuOption[id] = (g_menuOption[id] + 1) % (g_cstrike ? 3 : 2); + g_menuOption[id] = (g_menuOption[id] + 1) % 3; displayTeamMenu(id, g_menuPosition[id]) } case 8: displayTeamMenu(id, ++g_menuPosition[id]) @@ -674,18 +723,46 @@ public actionTeamMenu(id, key) default: { new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key] + if( !is_user_connected(player) ) // dunno why this check hasn't be implemented in the past + { + displayTeamMenu(id, g_menuPosition[id]) + return PLUGIN_HANDLED + } + + g_transferingAdmin = id + new authid[32], authid2[32], name[32], name2[32] get_user_name(player, name2, 31) get_user_authid(id, authid, 31) get_user_authid(player, authid2, 31) get_user_name(id, name, 31) - - log_amx("Cmd: ^"%s<%d><%s><>^" transfer ^"%s<%d><%s><>^" (team ^"%s^")", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2, g_menuOption[id] ? "TERRORIST" : "CT") - show_activity_key("ADMIN_TRANSF_1", "ADMIN_TRANSF_2", name, name2, g_CSTeamNames[g_menuOption[id] % 3]); + // This modulo math just aligns the option to the CsTeams-corresponding number + new destTeamSlot = (g_menuOption[id] % 3) + + log_amx("Cmd: ^"%s<%d><%s><>^" transfer ^"%s<%d><%s><>^" (team ^"%s^")", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2, g_CSTeamNames[destTeamSlot]) - if (g_cstrike) + show_activity_key("ADMIN_TRANSF_1", "ADMIN_TRANSF_2", name, name2, g_CSTeamNames[destTeamSlot]); + + + if( destTeamSlot == 2 ) + { + if ( g_fakemeta ) + { + if( get_pdata_int(player, m_iMenu) == Menu_ChooseAppearance ) + { + // works for both vgui and old style menus, and send menuselect could close other menus (and since get_user_menu fails to return VGUI and old style classes menus...) + engclient_cmd(player, "joinclass", "6"); + } + } + else // force + { + engclient_cmd(player, "joinclass", "6"); + } + } + + if ( g_CSPlayerCanSwitchFromSpec[player] && g_cstrike && (CS_TEAM_T <= cs_get_user_team(player) <= CS_TEAM_CT)) { if (is_user_alive(player)) { @@ -693,18 +770,59 @@ public actionTeamMenu(id, key) user_kill(player, 1) cs_set_user_deaths(player, deaths) } - // This modulo math just aligns the option to the CsTeams-corresponding number - cs_set_user_team(player, (g_menuOption[id] % 3) + 1) - cs_reset_user_model(player) - } else { - new limit_setting = get_cvar_num("mp_limitteams") - set_cvar_num("mp_limitteams", 0) - engclient_cmd(player, "jointeam", g_CSTeamNumbers[g_menuOption[id] % 2]) - engclient_cmd(player, "joinclass", "1") - set_cvar_num("mp_limitteams", limit_setting) + cs_set_user_team(player, destTeamSlot + 1) + + } else { + if (is_user_alive(player)) + { + user_kill(player, 1) + } + if( g_fakemeta ) + { + set_pdata_bool(player, m_bTeamChanged, true); + } + new limit_setting + if( mp_limitteams ) + { + limit_setting = get_pcvar_num(mp_limitteams) + + set_pcvar_num(mp_limitteams, 0) + } + + if( destTeamSlot == 2 ) + { + new Float:allow_spectators_setting + if( allow_spectators ) + { + allow_spectators_setting = get_pcvar_float(allow_spectators) + if( allow_spectators_setting != 1.0 ) + set_pcvar_float(allow_spectators, 1.0) + } + engclient_cmd(player, "jointeam", g_CSTeamNumbers[destTeamSlot]) + if( allow_spectators && allow_spectators_setting != 1.0 ) + set_pcvar_float(allow_spectators, allow_spectators_setting) + } + else + { + engclient_cmd(player, "jointeam", g_CSTeamNumbers[destTeamSlot]) + engclient_cmd(player, "joinclass", "1") + } + if( mp_limitteams && limit_setting != 0 ) + { + set_pcvar_num(mp_limitteams, limit_setting) + } + } + if( g_cstrike ) + { + cs_reset_user_model(player) + } + if( g_fakemeta ) + { + set_pdata_bool(player, m_bTeamChanged, true); } + g_transferingAdmin = 0 displayTeamMenu(id, g_menuPosition[id]) } } @@ -755,15 +873,19 @@ displayTeamMenu(id, pos) else if (iteam == 3) { copy(team, 3, "SPE"); - iteam = 6; + // iteam = 6; // oO WTF is this ?? fixed g_CSTeamiNumbers. } else { iteam = get_user_team(i, team, 3) } } else { iteam = get_user_team(i, team, 3) } + if( !iteam ) + { + iteam = 3 // fix get_user_team returning 0 on spectators + } - if ((iteam == g_CSTeamiNumbers[g_menuOption[id] % (g_cstrike ? 3 : 2)]) || (access(i, ADMIN_IMMUNITY) && i != id)) + if ((iteam == g_CSTeamiNumbers[g_menuOption[id] % 3]) || (access(i, ADMIN_IMMUNITY) && i != id)) { ++b @@ -781,7 +903,7 @@ displayTeamMenu(id, pos) } } - len += format(menuBody[len], 511-len, "^n8. %L^n", id, "TRANSF_TO", g_CSTeamNames[g_menuOption[id] % (g_cstrike ? 3 : 2)]) + len += format(menuBody[len], 511-len, "^n8. %L^n", id, "TRANSF_TO", g_CSTeamNames[g_menuOption[id] % 3]) if (end != g_menuPlayersNum[id]) {