new cleaned-up version of the plugins (no more OLOcode :D)
This commit is contained in:
@ -63,55 +63,68 @@ new g_clientMenuPlugin[MAXMENUS][STRINGSIZE]
|
||||
// menuCmd: Command that should be executed to start menu
|
||||
// menuAccess: Access required for menu
|
||||
// menuPlugin: The exact case-insensitive name of plugin holding the menu command
|
||||
public AddMenu(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[]) {
|
||||
if (g_menusNumber + 1 == MAXMENUS) {
|
||||
public AddMenu(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[])
|
||||
{
|
||||
if (g_menusNumber + 1 == MAXMENUS)
|
||||
{
|
||||
log_amx("Error: Plugin ^"%s^" tried to add a menu item to Menu Front-End plugin with maximum menu items reached!", menuPlugin)
|
||||
return
|
||||
}
|
||||
|
||||
copy(g_menuBody[g_menusNumber], STRINGLENGTH, menuBody)
|
||||
g_menuBodyPhrase[g_menusNumber] = false
|
||||
|
||||
copy(g_menuCmd[g_menusNumber], STRINGLENGTH, menuCmd)
|
||||
g_menuAccess[g_menusNumber] = menuAccess
|
||||
|
||||
copy(g_menuPlugin[g_menusNumber], STRINGLENGTH, menuPlugin)
|
||||
|
||||
g_menusNumber++
|
||||
|
||||
server_print("Menu item %d added to Menus Front-End: ^"%s^" from plugin ^"%s^"", g_menusNumber, menuBody, menuPlugin)
|
||||
}
|
||||
public AddMenuLang(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[]) {
|
||||
if (g_menusNumber + 1 == MAXMENUS) {
|
||||
|
||||
public AddMenuLang(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[])
|
||||
{
|
||||
if (g_menusNumber + 1 == MAXMENUS)
|
||||
{
|
||||
log_amx("Error: Plugin ^"%s^" tried to add a menu item to Menu Front-End plugin with maximum menu items reached!", menuPlugin)
|
||||
return
|
||||
}
|
||||
|
||||
copy(g_menuBody[g_menusNumber], STRINGLENGTH, menuBody)
|
||||
g_menuBodyPhrase[g_menusNumber] = true
|
||||
|
||||
copy(g_menuCmd[g_menusNumber], STRINGLENGTH, menuCmd)
|
||||
g_menuAccess[g_menusNumber] = menuAccess
|
||||
|
||||
copy(g_menuPlugin[g_menusNumber], STRINGLENGTH, menuPlugin)
|
||||
g_menusNumber++
|
||||
|
||||
//server_print("Menu item %d added to Menus Front-End: ^"%s^" (LANG) from plugin ^"%s^"", g_menusNumber, menuBody, menuPlugin)
|
||||
}
|
||||
public AddClientMenu(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[]) {
|
||||
if (g_clientMenusNumber + 1 == MAXMENUS) {
|
||||
|
||||
public AddClientMenu(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[])
|
||||
{
|
||||
if (g_clientMenusNumber + 1 == MAXMENUS)
|
||||
{
|
||||
log_amx("Error: Plugin ^"%s^" tried to add a menu item to Menu Front-End plugin with maximum menu items reached!", menuPlugin)
|
||||
return
|
||||
}
|
||||
|
||||
copy(g_clientMenuBody[g_clientMenusNumber], STRINGLENGTH, menuBody)
|
||||
g_clientMenuBodyPhrase[g_clientMenusNumber] = false
|
||||
|
||||
copy(g_clientMenuCmd[g_clientMenusNumber], STRINGLENGTH, menuCmd)
|
||||
g_clientMenuAccess[g_clientMenusNumber] = menuAccess
|
||||
|
||||
copy(g_clientMenuPlugin[g_clientMenusNumber], STRINGLENGTH, menuPlugin)
|
||||
|
||||
g_clientMenusNumber++
|
||||
|
||||
server_print("Client menu item %d added to Client Menus Front-End: ^"%s^" from plugin ^"%s^"", g_clientMenusNumber, menuBody, menuPlugin)
|
||||
}
|
||||
|
||||
AddDefaultMenus() {
|
||||
AddDefaultMenus()
|
||||
{
|
||||
AddMenuLang("KICK_PLAYER", "amx_kickmenu", ADMIN_KICK, "Players Menu")
|
||||
AddMenuLang("BAN_PLAYER", "amx_banmenu", ADMIN_BAN, "Players Menu")
|
||||
AddMenuLang("SLAP_SLAY", "amx_slapmenu", ADMIN_SLAY, "Players Menu")
|
||||
@ -130,24 +143,32 @@ AddDefaultMenus() {
|
||||
AddMenuLang("TELE_PLAYER", "amx_teleportmenu", ADMIN_LEVEL_A, "Teleport Menu")
|
||||
}
|
||||
|
||||
public actionMenu(id,key) {
|
||||
switch (key) {
|
||||
case 8: displayMenu(id,++g_menuPosition[id])
|
||||
case 9: displayMenu(id,--g_menuPosition[id])
|
||||
default: client_cmd(id, g_menuCmd[ g_menuPosition[id] * 8 + key ] )
|
||||
public actionMenu(id, key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 8: displayMenu(id, ++g_menuPosition[id])
|
||||
case 9: displayMenu(id, --g_menuPosition[id])
|
||||
default: client_cmd(id, g_menuCmd[g_menuPosition[id] * 8 + key])
|
||||
}
|
||||
|
||||
return PLUGIN_HANDLED
|
||||
}
|
||||
public clientActionMenu(id,key) {
|
||||
switch (key) {
|
||||
|
||||
public clientActionMenu(id, key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 8: clientDisplayMenu(id, ++g_clientMenuPosition[id])
|
||||
case 9: clientDisplayMenu(id, --g_clientMenuPosition[id])
|
||||
default: client_cmd(id, g_clientMenuCmd[ g_clientMenuPosition[id] * 8 + key ])
|
||||
default: client_cmd(id, g_clientMenuCmd[g_clientMenuPosition[id] * 8 + key])
|
||||
}
|
||||
|
||||
return PLUGIN_HANDLED
|
||||
}
|
||||
|
||||
displayMenu(id, pos) {
|
||||
displayMenu(id, pos)
|
||||
{
|
||||
if (pos < 0)
|
||||
return
|
||||
|
||||
@ -155,127 +176,139 @@ displayMenu(id, pos) {
|
||||
new b = 0
|
||||
new start = pos * MENUITEMSPERPAGE
|
||||
|
||||
if ( start >= g_menusNumber ) // MENUS_NUMBER
|
||||
if (start >= g_menusNumber) // MENUS_NUMBER
|
||||
start = pos = g_menuPosition[id] = 0
|
||||
|
||||
new len = format(menuBody,511,
|
||||
g_coloredMenus ? "\yAMX Mod X Menu\R%d/%d^n\w^n" : "AMX Mod X Menu %d/%d^n^n" , pos+1, (g_menusNumber / MENUITEMSPERPAGE) + (((g_menusNumber % MENUITEMSPERPAGE) > 0) ? 1 : 0))
|
||||
new len = format(menuBody, 511,
|
||||
|
||||
g_coloredMenus ? "\yAMX Mod X Menu\R%d/%d^n\w^n" : "AMX Mod X Menu %d/%d^n^n" , pos + 1, (g_menusNumber / MENUITEMSPERPAGE) + (((g_menusNumber % MENUITEMSPERPAGE) > 0) ? 1 : 0))
|
||||
|
||||
new end = start + MENUITEMSPERPAGE
|
||||
new keys = MENU_KEY_0
|
||||
|
||||
if (end > g_menusNumber ) // MENUS_NUMBER
|
||||
end = g_menusNumber // MENUS_NUMBER
|
||||
if (end > g_menusNumber) // MENUS_NUMBER
|
||||
end = g_menusNumber // MENUS_NUMBER
|
||||
|
||||
new flags = get_user_flags(id)
|
||||
|
||||
for (new a = start; a < end; ++a) {
|
||||
if ( (flags & g_menuAccess[a]) && ( is_plugin_loaded(g_menuPlugin[a])!=-1 ) ) {
|
||||
for (new a = start; a < end; ++a)
|
||||
{
|
||||
if ((flags & g_menuAccess[a]) && (is_plugin_loaded(g_menuPlugin[a]) != -1))
|
||||
{
|
||||
keys |= (1<<b)
|
||||
|
||||
if (g_menuBodyPhrase[a])
|
||||
len += format(menuBody[len],511-len,"%d. %L^n",++b, id, g_menuBody[ a ] )
|
||||
len += format(menuBody[len], 511-len, "%d. %L^n", ++b, id, g_menuBody[a])
|
||||
else
|
||||
len += format(menuBody[len],511-len,"%d. %s^n",++b, g_menuBody[ a ] )
|
||||
}
|
||||
else {
|
||||
len += format(menuBody[len], 511-len, "%d. %s^n", ++b, g_menuBody[a])
|
||||
} else {
|
||||
++b
|
||||
if ( g_coloredMenus ) {
|
||||
|
||||
if (g_coloredMenus)
|
||||
{
|
||||
if (g_menuBodyPhrase[a])
|
||||
len += format(menuBody[len],511-len, "\d%d. %L^n\w",b, id, g_menuBody[ a ] )
|
||||
len += format(menuBody[len], 511-len, "\d%d. %L^n\w", b, id, g_menuBody[a])
|
||||
else
|
||||
len += format(menuBody[len],511-len, "\d%d. %s^n\w",b, g_menuBody[ a ] )
|
||||
}
|
||||
else {
|
||||
len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, g_menuBody[a])
|
||||
} else {
|
||||
if (g_menuBodyPhrase[a])
|
||||
len += format(menuBody[len],511-len, "#. %L^n", id, g_menuBody[ a ] )
|
||||
len += format(menuBody[len], 511-len, "#. %L^n", id, g_menuBody[a])
|
||||
else
|
||||
len += format(menuBody[len],511-len, "#. %s^n", g_menuBody[ a ] )
|
||||
len += format(menuBody[len], 511-len, "#. %s^n", g_menuBody[a])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (end != g_menusNumber ) { // MENUS_NUMBER
|
||||
format(menuBody[len],511-len,"^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
|
||||
if (end != g_menusNumber) // MENUS_NUMBER
|
||||
{
|
||||
format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
|
||||
keys |= MENU_KEY_9
|
||||
}
|
||||
else {
|
||||
format(menuBody[len],511-len,"^n0. %L", id, pos ? "BACK" : "EXIT")
|
||||
}
|
||||
|
||||
show_menu(id,keys,menuBody)
|
||||
}
|
||||
clientDisplayMenu(id,pos) {
|
||||
if (pos < 0)
|
||||
return
|
||||
|
||||
new menuBody[512]
|
||||
new b = 0
|
||||
new start = pos * MENUITEMSPERPAGE
|
||||
|
||||
if ( start >= g_clientMenusNumber ) // MENUS_NUMBER
|
||||
start = pos = g_clientMenuPosition[id] = 0
|
||||
|
||||
new len = format(menuBody,511,
|
||||
g_coloredMenus ? "\yAMX Mod X Client Menu\R%d/%d^n\w^n" : "AMX Mod X Client Menu %d/%d^n^n" , pos+1, (g_clientMenusNumber / MENUITEMSPERPAGE) + (((g_clientMenusNumber % MENUITEMSPERPAGE) > 0) ? 1 : 0))
|
||||
|
||||
new end = start + MENUITEMSPERPAGE
|
||||
new keys = MENU_KEY_0
|
||||
|
||||
if (end > g_clientMenusNumber ) // MENUS_NUMBER
|
||||
end = g_clientMenusNumber // MENUS_NUMBER
|
||||
|
||||
new flags = get_user_flags(id)
|
||||
|
||||
for (new a = start; a < end; ++a) {
|
||||
if ( (flags & g_clientMenuAccess[a]) && ( is_plugin_loaded(g_clientMenuPlugin[a])!=-1 ) ) {
|
||||
keys |= (1<<b)
|
||||
if (g_clientMenuBodyPhrase[a])
|
||||
len += format(menuBody[len],511-len,"%d. %L^n",++b, id, g_clientMenuBody[ a ] )
|
||||
else
|
||||
len += format(menuBody[len],511-len,"%d. %s^n",++b, g_clientMenuBody[ a ] )
|
||||
}
|
||||
else {
|
||||
++b
|
||||
if ( g_coloredMenus ) {
|
||||
if (g_clientMenuBodyPhrase[a])
|
||||
len += format(menuBody[len],511-len, "\d%d. %L^n\w",b, id, g_clientMenuBody[ a ] )
|
||||
else
|
||||
len += format(menuBody[len],511-len, "\d%d. %s^n\w",b, g_clientMenuBody[ a ] )
|
||||
}
|
||||
else {
|
||||
if (g_clientMenuBodyPhrase[a])
|
||||
len += format(menuBody[len],511-len, "#. %L^n", id, g_clientMenuBody[ a ] )
|
||||
else
|
||||
len += format(menuBody[len],511-len, "#. %s^n", g_clientMenuBody[ a ] )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (end != g_clientMenusNumber ) { // MENUS_NUMBER
|
||||
format(menuBody[len],511-len,"^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
|
||||
keys |= MENU_KEY_9
|
||||
}
|
||||
else {
|
||||
format(menuBody[len],511-len,"^n0. %L", id, pos ? "BACK" : "EXIT")
|
||||
} else {
|
||||
format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
|
||||
}
|
||||
|
||||
show_menu(id, keys, menuBody)
|
||||
}
|
||||
|
||||
public cmdMenu(id,level,cid) {
|
||||
if (cmd_access(id,level,cid,1))
|
||||
displayMenu(id, g_menuPosition[id] = 0)
|
||||
clientDisplayMenu(id, pos)
|
||||
{
|
||||
if (pos < 0)
|
||||
return
|
||||
|
||||
return PLUGIN_HANDLED
|
||||
new menuBody[512]
|
||||
new b = 0
|
||||
new start = pos * MENUITEMSPERPAGE
|
||||
|
||||
if (start >= g_clientMenusNumber) // MENUS_NUMBER
|
||||
start = pos = g_clientMenuPosition[id] = 0
|
||||
|
||||
new len = format(menuBody, 511, g_coloredMenus ? "\yAMX Mod X Client Menu\R%d/%d^n\w^n" : "AMX Mod X Client Menu %d/%d^n^n" , pos + 1, (g_clientMenusNumber / MENUITEMSPERPAGE) + (((g_clientMenusNumber % MENUITEMSPERPAGE) > 0) ? 1 : 0))
|
||||
|
||||
new end = start + MENUITEMSPERPAGE
|
||||
new keys = MENU_KEY_0
|
||||
|
||||
if (end > g_clientMenusNumber) // MENUS_NUMBER
|
||||
end = g_clientMenusNumber // MENUS_NUMBER
|
||||
|
||||
new flags = get_user_flags(id)
|
||||
|
||||
for (new a = start; a < end; ++a)
|
||||
{
|
||||
if ((flags & g_clientMenuAccess[a]) && (is_plugin_loaded(g_clientMenuPlugin[a]) != -1))
|
||||
{
|
||||
keys |= (1<<b)
|
||||
|
||||
if (g_clientMenuBodyPhrase[a])
|
||||
len += format(menuBody[len], 511-len, "%d. %L^n", ++b, id, g_clientMenuBody[a])
|
||||
else
|
||||
len += format(menuBody[len], 511-len, "%d. %s^n", ++b, g_clientMenuBody[a])
|
||||
} else {
|
||||
++b
|
||||
|
||||
if (g_coloredMenus)
|
||||
{
|
||||
if (g_clientMenuBodyPhrase[a])
|
||||
len += format(menuBody[len], 511-len, "\d%d. %L^n\w", b, id, g_clientMenuBody[a])
|
||||
else
|
||||
len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, g_clientMenuBody[a])
|
||||
} else {
|
||||
if (g_clientMenuBodyPhrase[a])
|
||||
len += format(menuBody[len], 511-len, "#. %L^n", id, g_clientMenuBody[a])
|
||||
else
|
||||
len += format(menuBody[len], 511-len, "#. %s^n", g_clientMenuBody[a])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (end != g_clientMenusNumber) // MENUS_NUMBER
|
||||
{
|
||||
format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
|
||||
keys |= MENU_KEY_9
|
||||
}
|
||||
else {
|
||||
format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
|
||||
}
|
||||
|
||||
show_menu(id, keys, menuBody)
|
||||
}
|
||||
public clientCmdMenu(id,level,cid) {
|
||||
|
||||
public cmdMenu(id, level, cid)
|
||||
{
|
||||
if (cmd_access(id, level, cid, 1))
|
||||
displayMenu(id, g_menuPosition[id] = 0)
|
||||
|
||||
return PLUGIN_HANDLED
|
||||
}
|
||||
public clientCmdMenu(id, level, cid)
|
||||
{
|
||||
if (cmd_access(id, level, cid, 1))
|
||||
clientDisplayMenu(id, g_clientMenuPosition[id] = 0)
|
||||
|
||||
return PLUGIN_HANDLED
|
||||
}
|
||||
|
||||
public addmenuitem_cmd(id, level, cid) {
|
||||
public addmenuitem_cmd(id, level, cid)
|
||||
{
|
||||
if (!cmd_access(id, level, cid, 5))
|
||||
return PLUGIN_HANDLED
|
||||
|
||||
@ -287,12 +320,13 @@ public addmenuitem_cmd(id, level, cid) {
|
||||
menuAccess = read_flags(flags)
|
||||
read_argv(4, menuPlugin, STRINGLENGTH)
|
||||
|
||||
|
||||
AddMenu(menuBody, menuCmd, menuAccess, menuPlugin)
|
||||
|
||||
return PLUGIN_HANDLED
|
||||
}
|
||||
public addclientmenuitem_cmd(id, level, cid) {
|
||||
|
||||
public addclientmenuitem_cmd(id, level, cid)
|
||||
{
|
||||
if (!cmd_access(id, level, cid, 5))
|
||||
return PLUGIN_HANDLED
|
||||
|
||||
@ -304,15 +338,14 @@ public addclientmenuitem_cmd(id, level, cid) {
|
||||
menuAccess = read_flags(flags)
|
||||
read_argv(4, menuPlugin, STRINGLENGTH)
|
||||
|
||||
|
||||
AddClientMenu(menuBody, menuCmd, menuAccess, menuPlugin)
|
||||
|
||||
return PLUGIN_HANDLED
|
||||
}
|
||||
|
||||
public plugin_init() {
|
||||
register_plugin("Menus Front-End",AMXX_VERSION_STR,"AMXX Dev Team")
|
||||
|
||||
public plugin_init()
|
||||
{
|
||||
register_plugin("Menus Front-End", AMXX_VERSION_STR, "AMXX Dev Team")
|
||||
register_dictionary("menufront.txt")
|
||||
register_dictionary("common.txt")
|
||||
|
||||
@ -332,4 +365,4 @@ public plugin_init() {
|
||||
new configs[128]
|
||||
get_configsdir(configs, 127)
|
||||
server_cmd("exec %s/custommenuitems.cfg", configs)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user