amxmodx/plugins/plmenu.sma

732 lines
20 KiB
Plaintext
Raw Normal View History

2004-02-21 19:36:35 +00:00
/* AMX Mod X
* Players Menu Plugin
2004-01-31 20:56:22 +00:00
*
2004-02-21 19:36:35 +00:00
* by the AMX Mod X Development Team
* originally developed by OLO
2004-01-31 20:56:22 +00:00
*
2004-02-21 19:36:35 +00:00
* 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.
2004-01-31 20:56:22 +00:00
*/
2004-03-07 14:30:53 +00:00
#include <amxmodx>
#include <amxmisc>
2005-08-24 06:39:52 +00:00
#include <cstrike>
2004-01-31 20:56:22 +00:00
new g_menuPosition[33]
new g_menuPlayers[33][32]
new g_menuPlayersNum[33]
new g_menuOption[33]
new g_menuSettings[33]
new g_menuSelect[33][64]
new g_menuSelectNum[33]
2004-02-01 18:45:44 +00:00
#define MAX_CLCMDS 24
2004-01-31 20:56:22 +00:00
new g_clcmdName[MAX_CLCMDS][32]
new g_clcmdCmd[MAX_CLCMDS][64]
new g_clcmdMisc[MAX_CLCMDS][2]
new g_clcmdNum
new g_coloredMenus
2005-09-11 04:31:13 +00:00
new g_cstrike = 0
public plugin_natives()
{
set_module_filter("module_filter")
2005-09-11 04:32:40 +00:00
set_native_filter("native_filter")
2005-09-11 04:31:13 +00:00
}
2004-01-31 20:56:22 +00:00
public plugin_init() {
2004-07-30 23:39:39 +00:00
register_plugin("Players Menu",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("common.txt")
2004-08-22 04:25:55 +00:00
register_dictionary("admincmd.txt")
register_dictionary("plmenu.txt")
2004-01-31 20:56:22 +00:00
register_clcmd("amx_kickmenu","cmdKickMenu",ADMIN_KICK,"- displays kick menu")
register_clcmd("amx_banmenu","cmdBanMenu",ADMIN_BAN,"- displays ban menu")
register_clcmd("amx_slapmenu","cmdSlapMenu",ADMIN_SLAY,"- displays slap/slay menu")
register_clcmd("amx_teammenu","cmdTeamMenu",ADMIN_LEVEL_A,"- displays team menu")
register_clcmd("amx_clcmdmenu","cmdClcmdMenu",ADMIN_LEVEL_A,"- displays client cmds menu")
2004-01-31 20:56:22 +00:00
register_menucmd(register_menuid("Ban Menu"),1023,"actionBanMenu")
register_menucmd(register_menuid("Kick Menu"),1023,"actionKickMenu")
register_menucmd(register_menuid("Slap/Slay Menu"),1023,"actionSlapMenu")
register_menucmd(register_menuid("Team Menu"),1023,"actionTeamMenu")
register_menucmd(register_menuid("Client Cmds Menu"),1023,"actionClcmdMenu")
2004-01-31 20:56:22 +00:00
g_coloredMenus = colored_menus()
2004-01-31 20:56:22 +00:00
new clcmds_ini_file[64]
get_configsdir(clcmds_ini_file, 63)
format(clcmds_ini_file, 63, "%s/clcmds.ini", clcmds_ini_file)
2004-03-25 16:52:04 +00:00
load_settings(clcmds_ini_file)
2005-09-11 04:31:13 +00:00
if (module_exists("cstrike"))
g_cstrike = 1
}
public module_filter(const module[])
{
if (equali(module, "cstrike"))
return PLUGIN_HANDLED
return PLUGIN_CONTINUE
2004-01-31 20:56:22 +00:00
}
2005-09-11 04:32:40 +00:00
public native_filter(const name[], index, trap)
{
if (!trap)
return PLUGIN_HANDLED
return PLUGIN_CONTINUE
}
2004-01-31 20:56:22 +00:00
/* Ban menu */
public actionBanMenu(id,key) {
switch (key) {
case 7: {
/* BEGIN OF CHANGES BY MISTAGEE
ADDED A FEW MORE OPTIONS */
2004-01-31 20:56:22 +00:00
++g_menuOption[id]
g_menuOption[id] %= 7
2004-01-31 20:56:22 +00:00
switch(g_menuOption[id]){
case 0: g_menuSettings[id] = 0
case 1: g_menuSettings[id] = 5
case 2: g_menuSettings[id] = 10
case 3: g_menuSettings[id] = 15
case 4: g_menuSettings[id] = 30
case 5: g_menuSettings[id] = 45
case 6: g_menuSettings[id] = 60
}
2004-01-31 20:56:22 +00:00
displayBanMenu(id,g_menuPosition[id])
}
case 8: displayBanMenu(id,++g_menuPosition[id])
case 9: displayBanMenu(id,--g_menuPosition[id])
default: {
2004-01-31 20:56:22 +00:00
new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
2004-01-31 20:56:22 +00:00
new name[32], name2[32], authid[32],authid2[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)
new userid2 = get_user_userid(player)
log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%d^")",
2004-01-31 20:56:22 +00:00
name,get_user_userid(id),authid, name2,userid2,authid2, g_menuSettings[id] )
switch (get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"%L",LANG_PLAYER,"ADMIN_BAN_2",name,name2)
case 1: client_print(0,print_chat,"%L",LANG_PLAYER,"ADMIN_BAN_1",name2)
2004-01-31 20:56:22 +00:00
}
/* ---------- check for Steam ID added by MistaGee --------------------
IF AUTHID == 4294967295 OR VALVE_ID_LAN OR HLTV, BAN PER IP TO NOT BAN EVERYONE */
if ( (equal("4294967295",authid2)) || (equal("HLTV",authid2)) || (equali("VALVE_ID_LAN",authid2))) { /* lan or HLTV!*/ /* END OF MODIFICATIONS BY MISTAGEE */
2004-01-31 20:56:22 +00:00
new ipa[32]
get_user_ip(player,ipa,31,1)
server_cmd("addip %d %s;writeip",g_menuSettings[id],ipa)
}
else
server_cmd("banid %d #%d kick;writeid",g_menuSettings[id],userid2)
2004-01-31 20:56:22 +00:00
server_exec()
2004-01-31 20:56:22 +00:00
displayBanMenu(id,g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
displayBanMenu(id,pos) {
2004-01-31 20:56:22 +00:00
if (pos < 0) return
2004-01-31 20:56:22 +00:00
get_players(g_menuPlayers[id],g_menuPlayersNum[id])
2004-01-31 20:56:22 +00:00
new menuBody[512]
new b = 0
new i
new name[32]
new start = pos * 7
2004-01-31 20:56:22 +00:00
if (start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_coloredMenus ?
"\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n",
id,"BAN_MENU",pos+1,( g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0 )) )
2004-01-31 20:56:22 +00:00
new end = start + 7
2004-07-29 10:58:54 +00:00
new keys = MENU_KEY_0|MENU_KEY_8
2004-01-31 20:56:22 +00:00
if (end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
for (new a = start; a < end; ++a) {
2004-01-31 20:56:22 +00:00
i = g_menuPlayers[id][a]
get_user_name(i,name,31)
if ( is_user_bot(i) || access(i,ADMIN_IMMUNITY) ) {
++b
if ( g_coloredMenus )
2004-01-31 20:56:22 +00:00
len += format(menuBody[len],511-len,"\d%d. %s^n\w",b,name)
else
len += format(menuBody[len],511-len,"#. %s^n",name)
}
else {
2004-01-31 20:56:22 +00:00
keys |= (1<<b)
len += format(menuBody[len],511-len,"%d. %s^n",++b,name)
}
}
2004-01-31 20:56:22 +00:00
if ( g_menuSettings[id] )
len += format(menuBody[len],511-len,"^n8. %L^n", id, "BAN_FOR_MIN", g_menuSettings[id] )
2004-01-31 20:56:22 +00:00
else
len += format(menuBody[len],511-len,"^n8. %L^n", id, "BAN_PERM" )
if (end != g_menuPlayersNum[id]) {
format(menuBody[len],511-len,"^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
2004-07-29 10:58:54 +00:00
keys |= MENU_KEY_9
2004-01-31 20:56:22 +00:00
}
else format(menuBody[len],511-len,"^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id,keys,menuBody,-1,"Ban Menu")
2004-01-31 20:56:22 +00:00
}
public cmdBanMenu(id,level,cid) {
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
2004-01-31 20:56:22 +00:00
g_menuOption[id] = 1
g_menuSettings[id] = 5
displayBanMenu(id,g_menuPosition[id] = 0)
return PLUGIN_HANDLED
2004-01-31 20:56:22 +00:00
}
/* Slap/Slay */
public actionSlapMenu(id,key) {
switch (key) {
case 7: {
2004-01-31 20:56:22 +00:00
++g_menuOption[id]
g_menuOption[id] %= 4
switch (g_menuOption[id]) {
case 1: g_menuSettings[id] = 0
case 2: g_menuSettings[id] = 1
case 3: g_menuSettings[id] = 5
2004-01-31 20:56:22 +00:00
}
displaySlapMenu(id,g_menuPosition[id])
}
case 8: displaySlapMenu(id,++g_menuPosition[id])
case 9: displaySlapMenu(id,--g_menuPosition[id])
default: {
2004-01-31 20:56:22 +00:00
new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
2004-01-31 20:56:22 +00:00
new name2[32]
get_user_name(player,name2,31)
if (!is_user_alive(player)) {
client_print(id,print_chat,"%L",id,"CANT_PERF_DEAD",name2)
2004-01-31 20:56:22 +00:00
displaySlapMenu(id,g_menuPosition[id])
return PLUGIN_HANDLED
}
2004-01-31 20:56:22 +00:00
new authid[32],authid2[32], name[32]
get_user_authid(id,authid,31)
get_user_authid(player,authid2,31)
get_user_name(id,name,31)
2004-01-31 20:56:22 +00:00
if ( g_menuOption[id] ) {
log_amx("Cmd: ^"%s<%d><%s><>^" slap with %d damage ^"%s<%d><%s><>^"",
2004-01-31 20:56:22 +00:00
name,get_user_userid(id),authid, g_menuSettings[id], name2,get_user_userid(player),authid2 )
switch (get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"%L",LANG_PLAYER,"ADMIN_SLAP_2",name,name2,g_menuSettings[id])
case 1: client_print(0,print_chat,"%L",LANG_PLAYER,"ADMIN_SLAP_1",name2,g_menuSettings[id])
}
2004-01-31 20:56:22 +00:00
}
else {
log_amx("Cmd: ^"%s<%d><%s><>^" slay ^"%s<%d><%s><>^"",
2004-01-31 20:56:22 +00:00
name,get_user_userid(id),authid, name2,get_user_userid(player),authid2 )
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"%L",LANG_PLAYER,"ADMIN_SLAY_2",name,name2)
case 1: client_print(0,print_chat,"%L",LANG_PLAYER,"ADMIN_SLAY_1",name2)
2004-01-31 20:56:22 +00:00
}
}
2004-01-31 20:56:22 +00:00
if ( g_menuOption[id])
user_slap(player, ( get_user_health(player) > g_menuSettings[id] ) ? g_menuSettings[id] : 0 )
else
user_kill( player )
2004-01-31 20:56:22 +00:00
displaySlapMenu(id,g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
displaySlapMenu(id,pos) {
2004-01-31 20:56:22 +00:00
if (pos < 0) return
2004-01-31 20:56:22 +00:00
get_players(g_menuPlayers[id],g_menuPlayersNum[id])
2004-01-31 20:56:22 +00:00
new menuBody[512]
new b = 0
new i
new name[32], team[4]
new start = pos * 7
2004-01-31 20:56:22 +00:00
if (start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_coloredMenus ?
"\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n",
id,"SLAP_SLAY_MENU",pos+1,( g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0 )) )
2004-01-31 20:56:22 +00:00
new end = start + 7
2004-07-29 10:58:54 +00:00
new keys = MENU_KEY_0|MENU_KEY_8
2004-01-31 20:56:22 +00:00
if (end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
for (new a = start; a < end; ++a) {
2004-01-31 20:56:22 +00:00
i = g_menuPlayers[id][a]
get_user_name(i,name,31)
2005-09-11 04:31:13 +00:00
if (g_cstrike)
{
if (cs_get_user_team(i) == CS_TEAM_T)
{
2005-09-02 04:06:47 +00:00
copy(team, 3, "TE")
2005-09-11 07:17:31 +00:00
} else if (cs_get_user_team(i) == CS_TEAM_CT) {
copy(team, 3, "CT")
2005-09-11 04:31:13 +00:00
} else {
2005-09-02 04:06:47 +00:00
get_user_team(i,team,3)
2005-09-11 04:31:13 +00:00
}
} else {
get_user_team(i,team,3)
}
if ( !is_user_alive(i) || access(i,ADMIN_IMMUNITY) ) {
++b
if ( g_coloredMenus )
2004-01-31 20:56:22 +00:00
len += format(menuBody[len],511-len,"\d%d. %s\R%s^n\w", b,name,team)
else
len += format(menuBody[len],511-len,"#. %s %s^n",name,team)
}
else
{
keys |= (1<<b)
len += format(menuBody[len],511-len, g_coloredMenus ?
2004-01-31 20:56:22 +00:00
"%d. %s\y\R%s^n\w" : "%d. %s %s^n",++b,name,team)
}
}
if ( g_menuOption[id] )
len += format(menuBody[len],511-len,"^n8. %L^n",id,"SLAP_WITH_DMG",g_menuSettings[id] )
2004-01-31 20:56:22 +00:00
else
len += format(menuBody[len],511-len,"^n8. %L^n",id,"SLAY")
if (end != g_menuPlayersNum[id]) {
format(menuBody[len],511-len,"^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
2004-07-29 10:58:54 +00:00
keys |= MENU_KEY_9
2004-01-31 20:56:22 +00:00
}
else format(menuBody[len],511-len,"^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id,keys,menuBody,-1,"Slap/Slay Menu")
2004-01-31 20:56:22 +00:00
}
public cmdSlapMenu(id,level,cid)
{
if (!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
2004-01-31 20:56:22 +00:00
g_menuOption[id] = 0
g_menuSettings[id] = 0
2004-01-31 20:56:22 +00:00
displaySlapMenu(id,g_menuPosition[id] = 0)
return PLUGIN_HANDLED
2004-01-31 20:56:22 +00:00
}
/* Kick */
public actionKickMenu(id,key)
{
switch (key) {
case 8: displayKickMenu(id,++g_menuPosition[id])
case 9: displayKickMenu(id,--g_menuPosition[id])
default: {
2004-01-31 20:56:22 +00:00
new player = g_menuPlayers[id][g_menuPosition[id] * 8 + key]
2004-01-31 20:56:22 +00:00
new authid[32],authid2[32], name[32], name2[32]
get_user_authid(id,authid,31)
get_user_authid(player,authid2,31)
get_user_name(id,name,31)
get_user_name(player,name2,31)
2004-01-31 20:56:22 +00:00
new userid2 = get_user_userid(player)
log_amx("Kick: ^"%s<%d><%s><>^" kick ^"%s<%d><%s><>^"",
2004-01-31 20:56:22 +00:00
name,get_user_userid(id),authid, name2,userid2,authid2 )
switch (get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"%L",LANG_PLAYER,"ADMIN_KICK_2",name,name2)
case 1: client_print(0,print_chat,"%L",LANG_PLAYER,"ADMIN_KICK_1",name2)
2004-01-31 20:56:22 +00:00
}
2004-01-31 20:56:22 +00:00
server_cmd("kick #%d",userid2)
server_exec()
2004-01-31 20:56:22 +00:00
displayKickMenu(id,g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
displayKickMenu(id,pos) {
2004-01-31 20:56:22 +00:00
if (pos < 0) return
2004-01-31 20:56:22 +00:00
get_players(g_menuPlayers[id],g_menuPlayersNum[id])
2004-01-31 20:56:22 +00:00
new menuBody[512]
new b = 0
new i
new name[32]
new start = pos * 8
2004-01-31 20:56:22 +00:00
if (start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_coloredMenus ?
"\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n",
id,"KICK_MENU",pos+1,( g_menuPlayersNum[id] / 8 + ((g_menuPlayersNum[id] % 8) ? 1 : 0 )) )
2004-01-31 20:56:22 +00:00
new end = start + 8
2004-07-29 10:58:54 +00:00
new keys = MENU_KEY_0
2004-01-31 20:56:22 +00:00
if (end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
for (new a = start; a < end; ++a) {
2004-01-31 20:56:22 +00:00
i = g_menuPlayers[id][a]
get_user_name(i,name,31)
if ( access(i,ADMIN_IMMUNITY) ) {
++b
if ( g_coloredMenus )
2004-01-31 20:56:22 +00:00
len += format(menuBody[len],511-len,"\d%d. %s^n\w",b,name)
else
len += format(menuBody[len],511-len,"#. %s^n",name)
}
else {
2004-01-31 20:56:22 +00:00
keys |= (1<<b)
len += format(menuBody[len],511-len,"%d. %s^n",++b,name)
}
}
if (end != g_menuPlayersNum[id]) {
format(menuBody[len],511-len,"^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
2004-07-29 10:58:54 +00:00
keys |= MENU_KEY_9
2004-01-31 20:56:22 +00:00
}
else format(menuBody[len],511-len,"^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id,keys,menuBody,-1,"Kick Menu")
2004-01-31 20:56:22 +00:00
}
public cmdKickMenu(id,level,cid) {
2004-01-31 20:56:22 +00:00
if (cmd_access(id,level,cid,1))
displayKickMenu(id,g_menuPosition[id] = 0)
return PLUGIN_HANDLED
2004-01-31 20:56:22 +00:00
}
/* Team menu */
public actionTeamMenu(id,key) {
switch (key) {
case 7:{
2004-01-31 20:56:22 +00:00
g_menuOption[id] = 1 - g_menuOption[id]
displayTeamMenu(id,g_menuPosition[id])
}
case 8: displayTeamMenu(id,++g_menuPosition[id])
case 9: displayTeamMenu(id,--g_menuPosition[id])
default: {
2004-01-31 20:56:22 +00:00
new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
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^")",
2004-01-31 20:56:22 +00:00
name,get_user_userid(id),authid, name2,get_user_userid(player),authid2, g_menuOption[id] ? "TERRORIST" : "CT" )
switch (get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"%L",id,"ADMIN_TRANSF_2",name,name2,g_menuOption[id] ? "TERRORIST" : "CT" )
case 1: client_print(0,print_chat,"%L",id,"ADMIN_TRANSF_1",name2,g_menuOption[id] ? "TERRORIST" : "CT" )
2004-01-31 20:56:22 +00:00
}
2005-09-11 04:31:13 +00:00
if (g_cstrike)
{
cs_set_user_team(player, g_menuOption[id] ? 1 : 2)
2005-09-11 07:19:06 +00:00
cs_reset_user_model(player)
2005-09-11 04:31:13 +00:00
} else {
new limit_setting = get_cvar_num("mp_limitteams")
set_cvar_num("mp_limitteams", 0)
engclient_cmd(player, "jointeam", g_menuOption[id] ? "1" : "2")
engclient_cmd(player, "joinclass", "1")
set_cvar_num("mp_limitteams", limit_setting)
}
2004-01-31 20:56:22 +00:00
displayTeamMenu(id,g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
displayTeamMenu(id,pos) {
2004-01-31 20:56:22 +00:00
if (pos < 0) return
2004-01-31 20:56:22 +00:00
get_players(g_menuPlayers[id],g_menuPlayersNum[id])
2004-01-31 20:56:22 +00:00
new menuBody[512]
new b = 0
new i, iteam
new name[32], team[4]
new start = pos * 7
2004-01-31 20:56:22 +00:00
if (start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_coloredMenus ?
"\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n",
id,"TEAM_MENU",pos+1,( g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0 )) )
2004-01-31 20:56:22 +00:00
new end = start + 7
2004-07-29 10:58:54 +00:00
new keys = MENU_KEY_0|MENU_KEY_8
2004-01-31 20:56:22 +00:00
if (end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
for (new a = start; a < end; ++a) {
2004-01-31 20:56:22 +00:00
i = g_menuPlayers[id][a]
get_user_name(i,name,31)
2005-09-11 04:31:13 +00:00
if (g_cstrike)
{
iteam = _:cs_get_user_team(i)
if (iteam == 1) {
2005-09-02 04:06:47 +00:00
copy(team, 3, "TE")
2005-09-11 07:17:31 +00:00
} else if (iteam == 2) {
copy(team, 3, "CT")
2005-09-11 04:31:13 +00:00
} else {
2005-09-02 04:06:47 +00:00
get_user_team(i,team,3)
2005-09-11 04:31:13 +00:00
}
} else {
iteam = get_user_team(i,team,3)
}
if ( (iteam == (g_menuOption[id] ? 1 : 2)) || access(i,ADMIN_IMMUNITY) ) {
++b
if ( g_coloredMenus )
2004-01-31 20:56:22 +00:00
len += format(menuBody[len],511-len,"\d%d. %s\R%s^n\w",b,name,team)
else
len += format(menuBody[len],511-len,"#. %s %s^n",name,team)
}
else {
2004-01-31 20:56:22 +00:00
keys |= (1<<b)
len += format(menuBody[len],511-len, g_coloredMenus ?
2004-01-31 20:56:22 +00:00
"%d. %s\y\R%s^n\w" : "%d. %s %s^n",++b,name,team)
}
}
len += format(menuBody[len],511-len,"^n8. %L^n",id,"TRANSF_TO",g_menuOption[id] ? "TERRORIST" : "CT" )
2004-01-31 20:56:22 +00:00
if (end != g_menuPlayersNum[id])
{
format(menuBody[len],511-len,"^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
2004-07-29 10:58:54 +00:00
keys |= MENU_KEY_9
2004-01-31 20:56:22 +00:00
}
else format(menuBody[len],511-len,"^n0. %L", id, pos ? "BACK" : "EXIT")
2004-08-23 21:17:59 +00:00
show_menu(id,keys,menuBody,-1,"Team Menu")
2004-01-31 20:56:22 +00:00
}
public cmdTeamMenu(id,level,cid) {
2004-01-31 20:56:22 +00:00
if (!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
2004-01-31 20:56:22 +00:00
g_menuOption[id] = 0
displayTeamMenu(id,g_menuPosition[id] = 0)
return PLUGIN_HANDLED
2004-01-31 20:56:22 +00:00
}
/* Client cmds menu */
public actionClcmdMenu(id,key) {
switch (key) {
case 7:{
2004-01-31 20:56:22 +00:00
++g_menuOption[id]
g_menuOption[id] %= g_menuSelectNum[id]
displayClcmdMenu(id,g_menuPosition[id])
}
case 8: displayClcmdMenu(id,++g_menuPosition[id])
case 9: displayClcmdMenu(id,--g_menuPosition[id])
default: {
2004-01-31 20:56:22 +00:00
new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
new flags = g_clcmdMisc[g_menuSelect[id][g_menuOption[id]]][1]
if (is_user_connected(player)) {
new command[64], authid[32], name[32], userid[32]
copy(command,63,g_clcmdCmd[g_menuSelect[id][g_menuOption[id]]])
get_user_authid(player,authid,31)
get_user_name(player,name,31)
2004-03-08 17:34:37 +00:00
num_to_str(get_user_userid(player),userid,31)
2004-01-31 20:56:22 +00:00
replace(command,63,"%userid%",userid)
replace(command,63,"%authid%",authid)
replace(command,63,"%name%",name)
if (flags & 1) {
2004-01-31 20:56:22 +00:00
server_cmd(command)
server_exec()
}
else if (flags & 2)
client_cmd(id,command)
else if (flags & 4)
client_cmd(player,command)
}
if (flags & 8) displayClcmdMenu(id,g_menuPosition[id])
2004-01-31 20:56:22 +00:00
}
}
return PLUGIN_HANDLED
}
displayClcmdMenu(id,pos) {
if (pos < 0) return
2004-01-31 20:56:22 +00:00
get_players(g_menuPlayers[id],g_menuPlayersNum[id])
2004-01-31 20:56:22 +00:00
new menuBody[512]
new b = 0
new i
new name[32]
new start = pos * 7
2004-01-31 20:56:22 +00:00
if (start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_coloredMenus ?
"\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n",
id, "CL_CMD_MENU", pos+1,( g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0 )) )
2004-01-31 20:56:22 +00:00
new end = start + 7
2004-07-29 10:58:54 +00:00
new keys = MENU_KEY_0|MENU_KEY_8
2004-01-31 20:56:22 +00:00
if (end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
for (new a = start; a < end; ++a) {
2004-01-31 20:56:22 +00:00
i = g_menuPlayers[id][a]
get_user_name(i,name,31)
if ( !g_menuSelectNum[id] || access(i,ADMIN_IMMUNITY) ) {
++b
if ( g_coloredMenus )
2004-01-31 20:56:22 +00:00
len += format(menuBody[len],511-len,"\d%d. %s^n\w",b,name)
else
len += format(menuBody[len],511-len,"#. %s^n",name)
}
else {
2004-01-31 20:56:22 +00:00
keys |= (1<<b)
len += format(menuBody[len],511-len,"%d. %s^n",++b,name)
}
}
2004-01-31 20:56:22 +00:00
if ( g_menuSelectNum[id] )
len += format(menuBody[len],511-len,"^n8. %s^n", g_clcmdName[g_menuSelect[id][g_menuOption[id]]] )
else
len += format(menuBody[len],511-len,"^n8. %L^n",id,"NO_CMDS")
if (end != g_menuPlayersNum[id]) {
format(menuBody[len],511-len,"^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
2004-07-29 10:58:54 +00:00
keys |= MENU_KEY_9
2004-01-31 20:56:22 +00:00
}
else format(menuBody[len],511-len,"^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id,keys,menuBody,-1,"Client Cmds Menu")
2004-01-31 20:56:22 +00:00
}
public cmdClcmdMenu(id,level,cid) {
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
2004-01-31 20:56:22 +00:00
new flags = get_user_flags(id)
2004-01-31 20:56:22 +00:00
g_menuSelectNum[id] = 0
for (new a = 0; a < g_clcmdNum; ++a)
2004-01-31 20:56:22 +00:00
if (g_clcmdMisc[a][0] & flags)
g_menuSelect[id][g_menuSelectNum[id]++] = a
2004-01-31 20:56:22 +00:00
g_menuOption[id] = 0
2004-01-31 20:56:22 +00:00
displayClcmdMenu(id,g_menuPosition[id] = 0)
2004-01-31 20:56:22 +00:00
return PLUGIN_HANDLED
}
load_settings( szFilename[] ) {
if ( !file_exists ( szFilename ) )
2004-01-31 20:56:22 +00:00
return 0
2004-01-31 20:56:22 +00:00
new text[256], szFlags[32], szAccess[32]
new a, pos = 0
while ( g_clcmdNum < MAX_CLCMDS && read_file (szFilename,pos++,text,255,a) ) {
2004-01-31 20:56:22 +00:00
if ( text[0] == ';' ) continue
2004-01-31 20:56:22 +00:00
if ( parse( text , g_clcmdName[g_clcmdNum] , 31 ,
g_clcmdCmd[g_clcmdNum] ,63,szFlags,31,szAccess,31 ) > 3 )
{
2004-01-31 20:56:22 +00:00
while ( replace( g_clcmdCmd[ g_clcmdNum ] ,63,"\'","^"") ) {
// do nothing
}
2004-01-31 20:56:22 +00:00
g_clcmdMisc[ g_clcmdNum ][1] = read_flags ( szFlags )
g_clcmdMisc[ g_clcmdNum ][0] = read_flags ( szAccess )
g_clcmdNum++
2004-01-31 20:56:22 +00:00
}
}
2004-01-31 20:56:22 +00:00
return 1
2004-08-22 04:25:55 +00:00
}