Fix two player transfer issues in Players Menu plugin (bug 5850, r=arkshine)

Former-commit-id: 16f9e669369e6d2b5be6a39ba56b3c8f07b5a5f2
This commit is contained in:
connorr 2013-08-24 00:55:21 +02:00
parent d9fb9bac09
commit 73b365e952
2 changed files with 164 additions and 20 deletions

View File

@ -14,6 +14,7 @@ TEAM_MENU = Team Menu
TRANSF_TO = Transfer to %s TRANSF_TO = Transfer to %s
CL_CMD_MENU = Client Cmds Menu CL_CMD_MENU = Client Cmds Menu
NO_CMDS = No cmds available NO_CMDS = No cmds available
CANT_PERF_PLAYER = That action can't be performed on player "%s"
[de] [de]
ADMIN_BAN_1 = ADMIN: bannt %s ADMIN_BAN_1 = ADMIN: bannt %s
@ -31,6 +32,7 @@ TEAM_MENU = Menu > Team
TRANSF_TO = zu den %s geschoben TRANSF_TO = zu den %s geschoben
CL_CMD_MENU = Menu > Spielerbefehle CL_CMD_MENU = Menu > Spielerbefehle
NO_CMDS = keine Befehle verfuegbar NO_CMDS = keine Befehle verfuegbar
CANT_PERF_PLAYER = Diese Aktion kann nicht am spieler "%s" ausgefuehrt werden.
[sr] [sr]
ADMIN_BAN_1 = ADMIN: ban %s ADMIN_BAN_1 = ADMIN: ban %s
@ -48,6 +50,7 @@ TEAM_MENU = Tim Meni
TRANSF_TO = Transfer u %s TRANSF_TO = Transfer u %s
CL_CMD_MENU = Klijent Komande Meni CL_CMD_MENU = Klijent Komande Meni
NO_CMDS = Nema dostupnih komandi NO_CMDS = Nema dostupnih komandi
CANT_PERF_PLAYER = Komanda ne moze biti izvrsena na igrac "%s"
[tr] [tr]
ADMIN_BAN_1 = ADMIN: ban %s ADMIN_BAN_1 = ADMIN: ban %s
@ -65,6 +68,7 @@ TEAM_MENU = Takim menu
TRANSF_TO = %s takima goc TRANSF_TO = %s takima goc
CL_CMD_MENU = Oyuncu Emir Menusu CL_CMD_MENU = Oyuncu Emir Menusu
NO_CMDS = Emir mevcud degildir NO_CMDS = Emir mevcud degildir
CANT_PERF_PLAYER = Oyuncu uzerinde bunu yapamazsiniz "%s"
[fr] [fr]
ADMIN_BAN_1 = ADMIN: banni %s ADMIN_BAN_1 = ADMIN: banni %s
@ -82,6 +86,7 @@ TEAM_MENU = Menu Equipe
TRANSF_TO = Transferer en %s TRANSF_TO = Transferer en %s
CL_CMD_MENU = Menu Cmds Client CL_CMD_MENU = Menu Cmds Client
NO_CMDS = Aucune commande disponible NO_CMDS = Aucune commande disponible
CANT_PERF_PLAYER = Cette action ne peut pas etre faite sur le joueur "%s"
[sv] [sv]
ADMIN_BAN_1 = ADMIN: bannlys %s ADMIN_BAN_1 = ADMIN: bannlys %s
@ -99,6 +104,7 @@ TEAM_MENU = Lagmeny
TRANSF_TO = Skicka till %s TRANSF_TO = Skicka till %s
CL_CMD_MENU = Klientkommandomeny CL_CMD_MENU = Klientkommandomeny
NO_CMDS = Det finns inga kommandon NO_CMDS = Det finns inga kommandon
CANT_PERF_PLAYER = Den handlingen kan inte utf'o'ras pa spelare "%s"
[da] [da]
ADMIN_BAN_1 = ADMIN: ban %s ADMIN_BAN_1 = ADMIN: ban %s
@ -116,6 +122,7 @@ TEAM_MENU = Hold Menu
TRANSF_TO = Overflyt til %s TRANSF_TO = Overflyt til %s
CL_CMD_MENU = Klient Kommando Menu CL_CMD_MENU = Klient Kommando Menu
NO_CMDS = Ingen kommandoer til raadighed NO_CMDS = Ingen kommandoer til raadighed
CANT_PERF_PLAYER = Den handling kan ikke udfoeres paa spiller "%s"
[pl] [pl]
ADMIN_BAN_1 = Admin zbanowal %s ADMIN_BAN_1 = Admin zbanowal %s
@ -133,6 +140,7 @@ TEAM_MENU = Menu druzyny
TRANSF_TO = Przejdz do %s TRANSF_TO = Przejdz do %s
CL_CMD_MENU = menu komend klienta CL_CMD_MENU = menu komend klienta
NO_CMDS = Nie ma zadnych komend NO_CMDS = Nie ma zadnych komend
CANT_PERF_PLAYER = Nie mozesz tego wykonac na gracz "%s"
[nl] [nl]
ADMIN_BAN_1 = ADMIN: ban %s ADMIN_BAN_1 = ADMIN: ban %s
@ -150,6 +158,7 @@ TEAM_MENU = Teammenu
TRANSF_TO = Zet over naar %s TRANSF_TO = Zet over naar %s
CL_CMD_MENU = Gebruikerscommandomenu CL_CMD_MENU = Gebruikerscommandomenu
NO_CMDS = Geen cmds beschikbaar NO_CMDS = Geen cmds beschikbaar
CANT_PERF_PLAYER = Die actie kan niet worden uitgevoerd op speler "%s"
[es] [es]
ADMIN_BAN_1 = ADMIN: %s baneado ADMIN_BAN_1 = ADMIN: %s baneado
@ -167,6 +176,7 @@ TEAM_MENU = Menu de Equipos
TRANSF_TO = Transferir a los %s TRANSF_TO = Transferir a los %s
CL_CMD_MENU = Menu de Comandos de Cliente CL_CMD_MENU = Menu de Comandos de Cliente
NO_CMDS = No hay comandos disponibles NO_CMDS = No hay comandos disponibles
CANT_PERF_PLAYER = Esta accion no se puede aplicar a jugador "%s"
[bp] [bp]
ADMIN_BAN_1 = ADMIN: baniu %s ADMIN_BAN_1 = ADMIN: baniu %s
@ -184,6 +194,7 @@ TEAM_MENU = Menu de Controle de Time
TRANSF_TO = Transferir para %s TRANSF_TO = Transferir para %s
CL_CMD_MENU = Menu de Comandos no Cliente CL_CMD_MENU = Menu de Comandos no Cliente
NO_CMDS = Sem comandos disponiveis NO_CMDS = Sem comandos disponiveis
CANT_PERF_PLAYER = Aquela acao nao pode ser executada com jogador "%s"
[cz] [cz]
ADMIN_BAN_1 = ADMIN: zabanoval %s ADMIN_BAN_1 = ADMIN: zabanoval %s
@ -201,6 +212,7 @@ TEAM_MENU = Menu Tymu
TRANSF_TO = Premistit k %s TRANSF_TO = Premistit k %s
CL_CMD_MENU = Menu klientskych prikazu CL_CMD_MENU = Menu klientskych prikazu
NO_CMDS = Zadny cmds NO_CMDS = Zadny cmds
CANT_PERF_PLAYER = Tato operace nelze provest na hrac "%s"
[fi] [fi]
ADMIN_BAN_1 = ADMIN: bannasi %s ADMIN_BAN_1 = ADMIN: bannasi %s
@ -218,6 +230,7 @@ TEAM_MENU = Joukkuevalikko
TRANSF_TO = Siirra %s.ksi TRANSF_TO = Siirra %s.ksi
CL_CMD_MENU = Clientkomentovalikko CL_CMD_MENU = Clientkomentovalikko
NO_CMDS = Ei komentoja kaytettavissa NO_CMDS = Ei komentoja kaytettavissa
CANT_PERF_PLAYER = Tuota toimintoa ei voida suorittaa pelaaja "%s"
[ls] [ls]
ADMIN_BAN_1 = ADMIN: b4nz0|2 %s ADMIN_BAN_1 = ADMIN: b4nz0|2 %s
@ -235,6 +248,7 @@ TEAM_MENU = T34m M3nu
TRANSF_TO = Tr4nsf3r t0 %s TRANSF_TO = Tr4nsf3r t0 %s
CL_CMD_MENU = (li3nt (mds M3nu CL_CMD_MENU = (li3nt (mds M3nu
NO_CMDS = |\|0 cmds 4v4il4bl3 NO_CMDS = |\|0 cmds 4v4il4bl3
CANT_PERF_PLAYER = "%s" iz 4 l33t p|4y3r!
[bg] [bg]
ADMIN_BAN_1 = ADMINISTRATOR: banna %s ADMIN_BAN_1 = ADMINISTRATOR: banna %s
@ -252,6 +266,7 @@ TEAM_MENU = Otborno Menu
TRANSF_TO = Transferirai kam %s TRANSF_TO = Transferirai kam %s
CL_CMD_MENU = Klient Comandno Menu CL_CMD_MENU = Klient Comandno Menu
NO_CMDS = Nqma nikakvi pozvoleni comandi NO_CMDS = Nqma nikakvi pozvoleni comandi
CANT_PERF_PLAYER = Tazi comanda nemoje da se izpolzva na igra4 "%s"
[ro] [ro]
ADMIN_BAN_1 = ADMIN: ban %s ADMIN_BAN_1 = ADMIN: ban %s
@ -269,6 +284,7 @@ TEAM_MENU = Menu Echipe
TRANSF_TO = Transfera la %s TRANSF_TO = Transfera la %s
CL_CMD_MENU = Menu Comenzi Jucator CL_CMD_MENU = Menu Comenzi Jucator
NO_CMDS = Nici o comanda valabila NO_CMDS = Nici o comanda valabila
CANT_PERF_PLAYER = Aceasta comanda nu poate fi executata pe jucatorul "%s"
[hu] [hu]
ADMIN_BAN_1 = ADMIN: %s banolva ADMIN_BAN_1 = ADMIN: %s banolva
@ -286,6 +302,7 @@ TEAM_MENU = CSapat Menu
TRANSF_TO = Atallitva %s-nek TRANSF_TO = Atallitva %s-nek
CL_CMD_MENU = Client Cmds Menu CL_CMD_MENU = Client Cmds Menu
NO_CMDS = Nincs elerheto parancs NO_CMDS = Nincs elerheto parancs
CANT_PERF_PLAYER = Ezt az akciot nem hajthatod vegre "%s"-on jatekos
[lt] [lt]
ADMIN_BAN_1 = ADMINAS: isbanino %s ADMIN_BAN_1 = ADMINAS: isbanino %s
@ -303,6 +320,7 @@ TEAM_MENU = Komandos meniu
TRANSF_TO = Issiusti i %s TRANSF_TO = Issiusti i %s
CL_CMD_MENU = Klientu CMD meniu CL_CMD_MENU = Klientu CMD meniu
NO_CMDS = Nera galimu CMD NO_CMDS = Nera galimu CMD
CANT_PERF_PLAYER = Sio veiksmo negalima naudoti ant jaidejui "%s"
[sk] [sk]
ADMIN_BAN_1 = ADMIN: zabanoval %s ADMIN_BAN_1 = ADMIN: zabanoval %s
@ -320,6 +338,7 @@ TEAM_MENU = MENU: Tym
TRANSF_TO = Premiestnit k %s TRANSF_TO = Premiestnit k %s
CL_CMD_MENU = MENU: klientske prikazy CL_CMD_MENU = MENU: klientske prikazy
NO_CMDS = Ziadny cmds NO_CMDS = Ziadny cmds
CANT_PERF_PLAYER = Tato operacia nejde previest na hrac "%s"
[mk] [mk]
ADMIN_BAN_1 = ADMIN: ban %s ADMIN_BAN_1 = ADMIN: ban %s
@ -337,6 +356,7 @@ TEAM_MENU = Meni za timot
TRANSF_TO = Transfer vo %s TRANSF_TO = Transfer vo %s
CL_CMD_MENU = Meni so komandi za klientite CL_CMD_MENU = Meni so komandi za klientite
NO_CMDS = Nema dostapni komandi NO_CMDS = Nema dostapni komandi
CANT_PERF_PLAYER = Komandata ne moze da bide izvrsena na igrac "%s"
[hr] [hr]
ADMIN_BAN_1 = ADMIN: banao %s ADMIN_BAN_1 = ADMIN: banao %s
@ -354,6 +374,7 @@ TEAM_MENU = Izbornik timova
TRANSF_TO = Transfer u %s TRANSF_TO = Transfer u %s
CL_CMD_MENU = Izbornik naredbi klijenta CL_CMD_MENU = Izbornik naredbi klijenta
NO_CMDS = Nema dostupnih naredbi NO_CMDS = Nema dostupnih naredbi
CANT_PERF_PLAYER = That action can't be performed on player "%s"
[bs] [bs]
ADMIN_BAN_1 = ADMIN: ban %s ADMIN_BAN_1 = ADMIN: ban %s
@ -371,4 +392,5 @@ TEAM_MENU = Tim Meni
TRANSF_TO = Transfer u %s TRANSF_TO = Transfer u %s
CL_CMD_MENU = Klijent Komande Meni CL_CMD_MENU = Klijent Komande Meni
NO_CMDS = Nema dostupnih komand NO_CMDS = Nema dostupnih komand
CANT_PERF_PLAYER = That action can't be performed on player "%s"

View File

@ -38,6 +38,7 @@
/** skip autoloading since it's optional */ /** skip autoloading since it's optional */
#define AMXMODX_NOAUTOLOAD #define AMXMODX_NOAUTOLOAD
#include <cstrike> #include <cstrike>
#include <fakemeta>
new g_menuPosition[33] new g_menuPosition[33]
new g_menuPlayers[33][32] new g_menuPlayers[33][32]
@ -57,6 +58,7 @@ new g_clcmdNum
new g_coloredMenus new g_coloredMenus
new g_cstrike = 0 new g_cstrike = 0
new g_fakemeta = 0, m_iMenu, m_bTeamChanged, Menu_ChooseAppearance
new Array:g_bantimes; new Array:g_bantimes;
new Array:g_slapsettings; new Array:g_slapsettings;
@ -74,9 +76,14 @@ new g_CSTeamNumbers[3][] = {
new g_CSTeamiNumbers[3] = { new g_CSTeamiNumbers[3] = {
1, 1,
2, 2,
6 3
} }
new g_CSPlayerCanSwitchFromSpec[33]
new g_transferingAdmin
new allow_spectators, mp_limitteams
new p_amx_tempban_maxtime; new p_amx_tempban_maxtime;
new Trie:g_tempBans; new Trie:g_tempBans;
@ -135,8 +142,26 @@ public plugin_init()
format(clcmds_ini_file, 63, "%s/clcmds.ini", clcmds_ini_file) format(clcmds_ini_file, 63, "%s/clcmds.ini", clcmds_ini_file)
load_settings(clcmds_ini_file) load_settings(clcmds_ini_file)
if (module_exists("cstrike")) if (LibraryExists("cstrike", LibType_Library))
g_cstrike = 1 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() public plugin_cfg()
@ -207,7 +232,7 @@ public plmenu_setslapdmg()
} }
public module_filter(const module[]) public module_filter(const module[])
{ {
if (equali(module, "cstrike")) if (equali(module, "cstrike") || equali(module, "fakemeta"))
return PLUGIN_HANDLED return PLUGIN_HANDLED
return PLUGIN_CONTINUE return PLUGIN_CONTINUE
@ -660,13 +685,37 @@ public cmdKickMenu(id, level, cid)
/* Team menu */ /* 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) public actionTeamMenu(id, key)
{ {
switch (key) switch (key)
{ {
case 7: 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]) displayTeamMenu(id, g_menuPosition[id])
} }
case 8: displayTeamMenu(id, ++g_menuPosition[id]) case 8: displayTeamMenu(id, ++g_menuPosition[id])
@ -674,6 +723,14 @@ public actionTeamMenu(id, key)
default: default:
{ {
new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key] 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] new authid[32], authid2[32], name[32], name2[32]
get_user_name(player, name2, 31) get_user_name(player, name2, 31)
@ -681,11 +738,31 @@ public actionTeamMenu(id, key)
get_user_authid(player, authid2, 31) get_user_authid(player, authid2, 31)
get_user_name(id, name, 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") // This modulo math just aligns the option to the CsTeams-corresponding number
new destTeamSlot = (g_menuOption[id] % 3)
show_activity_key("ADMIN_TRANSF_1", "ADMIN_TRANSF_2", name, name2, g_CSTeamNames[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)) if (is_user_alive(player))
{ {
@ -693,18 +770,59 @@ public actionTeamMenu(id, key)
user_kill(player, 1) user_kill(player, 1)
cs_set_user_deaths(player, deaths) 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) cs_set_user_team(player, destTeamSlot + 1)
engclient_cmd(player, "jointeam", g_CSTeamNumbers[g_menuOption[id] % 2])
engclient_cmd(player, "joinclass", "1") } else {
set_cvar_num("mp_limitteams", limit_setting) 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]) displayTeamMenu(id, g_menuPosition[id])
} }
} }
@ -755,15 +873,19 @@ displayTeamMenu(id, pos)
else if (iteam == 3) else if (iteam == 3)
{ {
copy(team, 3, "SPE"); copy(team, 3, "SPE");
iteam = 6; // iteam = 6; // oO WTF is this ?? fixed g_CSTeamiNumbers.
} else { } else {
iteam = get_user_team(i, team, 3) iteam = get_user_team(i, team, 3)
} }
} else { } else {
iteam = get_user_team(i, team, 3) 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 ++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]) if (end != g_menuPlayersNum[id])
{ {