Update cmdmenu.sma
Changed format with formatex where needed, removed many hardcoded contents in plugin and added semicolons.
This commit is contained in:
parent
39cc240a4e
commit
b77c8e253b
|
@ -26,81 +26,81 @@ new g_cmdMenuName[MAX_CMDS_LAYERS][] =
|
||||||
"CMD_MENU",
|
"CMD_MENU",
|
||||||
"CONF_MENU",
|
"CONF_MENU",
|
||||||
"SPE_MENU"
|
"SPE_MENU"
|
||||||
}
|
};
|
||||||
|
|
||||||
new g_cmdMenuCmd[MAX_CMDS_LAYERS][] =
|
new g_cmdMenuCmd[MAX_CMDS_LAYERS][] =
|
||||||
{
|
{
|
||||||
"amx_cmdmenu",
|
"amx_cmdmenu",
|
||||||
"amx_cfgmenu",
|
"amx_cfgmenu",
|
||||||
"amx_speechmenu"
|
"amx_speechmenu"
|
||||||
}
|
};
|
||||||
|
|
||||||
new g_cmdMenuCfg[MAX_CMDS_LAYERS][] =
|
new g_cmdMenuCfg[MAX_CMDS_LAYERS][] =
|
||||||
{
|
{
|
||||||
"cmds.ini",
|
"cmds.ini",
|
||||||
"configs.ini",
|
"configs.ini",
|
||||||
"speech.ini"
|
"speech.ini"
|
||||||
}
|
};
|
||||||
|
|
||||||
new g_cmdMenuHelp[MAX_CMDS_LAYERS][] =
|
new g_cmdMenuHelp[MAX_CMDS_LAYERS][] =
|
||||||
{
|
{
|
||||||
"- displays commands menu",
|
"- displays commands menu",
|
||||||
"- displays configs menu",
|
"- displays configs menu",
|
||||||
"- displays speech menu"
|
"- displays speech menu"
|
||||||
}
|
};
|
||||||
|
|
||||||
/* End of Commands Menu */
|
/* End of Commands Menu */
|
||||||
|
|
||||||
#define MAX_CMDS 64
|
#define MAX_CMDS 64
|
||||||
#define MAX_CVARS 48
|
#define MAX_CVARS 48
|
||||||
|
|
||||||
new g_cmdName[MAX_CMDS*MAX_CMDS_LAYERS][32]
|
new g_cmdName[MAX_CMDS*MAX_CMDS_LAYERS][32];
|
||||||
new g_cmdCmd[MAX_CMDS*MAX_CMDS_LAYERS][64]
|
new g_cmdCmd[MAX_CMDS*MAX_CMDS_LAYERS][64];
|
||||||
new g_cmdMisc[MAX_CMDS*MAX_CMDS_LAYERS][2]
|
new g_cmdMisc[MAX_CMDS*MAX_CMDS_LAYERS][2];
|
||||||
new g_cmdNum[MAX_CMDS_LAYERS]
|
new g_cmdNum[MAX_CMDS_LAYERS];
|
||||||
|
|
||||||
new g_cvarNames[MAX_CVARS][32]
|
new g_cvarNames[MAX_CVARS][32];
|
||||||
new g_cvarMisc[MAX_CVARS][3]
|
new g_cvarMisc[MAX_CVARS][3];
|
||||||
new g_cvarCmd[MAX_CVARS*5][32]
|
new g_cvarCmd[MAX_CVARS*5][32];
|
||||||
new g_cvarCmdNum
|
new g_cvarCmdNum;
|
||||||
new g_cvarNum
|
new g_cvarNum;
|
||||||
|
|
||||||
new g_menuPosition[MAX_PLAYERS + 1]
|
new g_menuPosition[MAX_PLAYERS + 1];
|
||||||
new g_menuSelect[MAX_PLAYERS + 1][MAX_CMDS]
|
new g_menuSelect[MAX_PLAYERS + 1][MAX_CMDS];
|
||||||
new g_menuSelectNum[MAX_PLAYERS + 1]
|
new g_menuSelectNum[MAX_PLAYERS + 1];
|
||||||
new g_menuLayer[MAX_PLAYERS + 1]
|
new g_menuLayer[MAX_PLAYERS + 1];
|
||||||
|
|
||||||
new g_coloredMenus
|
new g_coloredMenus;
|
||||||
|
|
||||||
|
|
||||||
public plugin_init()
|
public plugin_init()
|
||||||
{
|
{
|
||||||
register_plugin("Commands Menu", AMXX_VERSION_STR, "AMXX Dev Team")
|
register_plugin("Commands Menu", AMXX_VERSION_STR, "AMXX Dev Team");
|
||||||
register_dictionary("cmdmenu.txt")
|
register_dictionary("cmdmenu.txt");
|
||||||
register_dictionary("common.txt")
|
register_dictionary("common.txt");
|
||||||
|
|
||||||
new configsDir[64], config[64]
|
new configsDir[64], config[64];
|
||||||
get_configsdir(configsDir, charsmax(configsDir))
|
get_configsdir(configsDir, charsmax(configsDir));
|
||||||
|
|
||||||
for (new a = 0; a < MAX_CMDS_LAYERS; ++a)
|
for (new a = 0; a < MAX_CMDS_LAYERS; ++a)
|
||||||
{
|
{
|
||||||
new MenuName[64]
|
new MenuName[64];
|
||||||
|
|
||||||
format(MenuName, charsmax(MenuName), "%L", "en", g_cmdMenuName[a])
|
formatex(MenuName, charsmax(MenuName), "%L", "en", g_cmdMenuName[a]);
|
||||||
register_menucmd(register_menuid(MenuName), 1023, "actionCmdMenu")
|
register_menucmd(register_menuid(MenuName), 1023, "actionCmdMenu");
|
||||||
register_clcmd(g_cmdMenuCmd[a], "cmdCmdMenu", ADMIN_MENU, g_cmdMenuHelp[a])
|
register_clcmd(g_cmdMenuCmd[a], "cmdCmdMenu", ADMIN_MENU, g_cmdMenuHelp[a]);
|
||||||
format(config, charsmax(config), "%s/%s", configsDir, g_cmdMenuCfg[a])
|
formatex(config, charsmax(config), "%s/%s", configsDir, g_cmdMenuCfg[a]);
|
||||||
loadCmdSettings(config, a)
|
loadCmdSettings(config, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
register_menucmd(register_menuid("Cvars Menu"), 1023, "actionCvarMenu")
|
register_menucmd(register_menuid("Cvars Menu"), 1023, "actionCvarMenu");
|
||||||
register_clcmd("amx_cvarmenu", "cmdCvarMenu", ADMIN_CVAR, "- displays cvars menu")
|
register_clcmd("amx_cvarmenu", "cmdCvarMenu", ADMIN_CVAR, "- displays cvars menu");
|
||||||
|
|
||||||
new cvars_ini_file[64];
|
new cvars_ini_file[64];
|
||||||
format(cvars_ini_file, charsmax(cvars_ini_file), "%s/%s", configsDir, "cvars.ini");
|
formatex(cvars_ini_file, charsmax(cvars_ini_file), "%s/%s", configsDir, "cvars.ini");
|
||||||
loadCvarSettings(cvars_ini_file)
|
loadCvarSettings(cvars_ini_file);
|
||||||
|
|
||||||
g_coloredMenus = colored_menus()
|
g_coloredMenus = colored_menus();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined PRECACHE_SPEECHINI
|
#if defined PRECACHE_SPEECHINI
|
||||||
|
@ -113,25 +113,32 @@ public plugin_precache( )
|
||||||
new fp = fopen( config, "rt" ); // Read file as text
|
new fp = fopen( config, "rt" ); // Read file as text
|
||||||
|
|
||||||
if ( ! fp ) // File doesn't exists
|
if ( ! fp ) // File doesn't exists
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
new szText[256];
|
new szText[256];
|
||||||
new line = 0;
|
new line = 0;
|
||||||
new szName[32], szSound[128], sndExt[5];
|
new szName[32], szSound[128], sndExt[5];
|
||||||
new field1[32], field2[64], field3[64];
|
new field1[32], field2[64], field3[64];
|
||||||
new fieldNums = 0;
|
new fieldNums = 0;
|
||||||
|
new const voxIdent[] = "vox", fvoxIdent[] = "fvox", barneyIdent[] = "barney", hgruntIdent[] = "hgrunt";
|
||||||
|
|
||||||
while ( line < MAX_CMDS && ! feof( fp ) ) // Loop till MAX_CMDS or EOF
|
while ( line < MAX_CMDS && ! feof( fp ) ) // Loop till MAX_CMDS or EOF
|
||||||
{
|
{
|
||||||
fgets( fp, szText, 255 ); // Store line content
|
fgets( fp, szText, charsmax(szText) ); // Store line content
|
||||||
|
|
||||||
/* Strips newline */
|
/* Strips newline */
|
||||||
new len = strlen( szText );
|
new len = strlen( szText );
|
||||||
if ( len != 0 && szText[len-1] == '^n' ) // len != 0 because if the last line of the file is empty, there's no newline
|
if ( len != 0 && szText[len-1] == '^n' ) // len != 0 because if the last line of the file is empty, there's no newline
|
||||||
|
{
|
||||||
szText[--len] = 0;
|
szText[--len] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ( len == 0 || szText[0] == ';' || szText[0] == '/' ) // Line is empty or a comment
|
if ( len == 0 || szText[0] == ';' || szText[0] == '/' ) // Line is empty or a comment
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
parse( szText, szName, charsmax(szName), szSound, charsmax(szSound) );
|
parse( szText, szName, charsmax(szName), szSound, charsmax(szSound) );
|
||||||
fieldNums = parse( szSound, field1, charsmax(field1), field2, charsmax(field2), field3, charsmax(field3) );
|
fieldNums = parse( szSound, field1, charsmax(field1), field2, charsmax(field2), field3, charsmax(field3) );
|
||||||
|
@ -151,15 +158,21 @@ public plugin_precache( )
|
||||||
replace_all( szSound, charsmax(szSound), "\'", "" ); // Strips all ugly (and sometimes useless) \'
|
replace_all( szSound, charsmax(szSound), "\'", "" ); // Strips all ugly (and sometimes useless) \'
|
||||||
|
|
||||||
if ( szSound[0] == '/' )
|
if ( szSound[0] == '/' )
|
||||||
|
{
|
||||||
replace( szSound, charsmax(szSound), "/", "" ); // Strip leading slash
|
replace( szSound, charsmax(szSound), "/", "" ); // Strip leading slash
|
||||||
|
}
|
||||||
|
|
||||||
if ( sndExt[1] == 'm' || ( ! equali( szSound, "vox", 3 ) && ! equali( szSound, "fvox", 4 ) && ! equali( szSound, "barney", 6 ) && ! equali( szSound, "hgrunt", 6 ) ) )
|
if ( sndExt[1] == 'm' || ( ! equali( szSound, voxIdent, charsmax(voxIdent) ) && ! equali( szSound, fvoxIdent, charsmax(fvoxIdent) ) && ! equali( szSound, barneyIdent, charsmax(barneyIdent) ) && ! equali( szSound, hgruntIdent, charsmax(hgruntIdent) ) ) )
|
||||||
{
|
{
|
||||||
// SzSound is a mp3, or a custom wav (not a vox, fvox, or default sound from HL pak)
|
// SzSound is a mp3, or a custom wav (not a vox, fvox, or default sound from HL pak)
|
||||||
if ( !equali( szSound[strlen(szSound)-4], sndExt ) )
|
if ( !equali( szSound[strlen(szSound)-4], sndExt ) )
|
||||||
|
{
|
||||||
add( szSound, charsmax(szSound), sndExt ); // Add filetype extension if it isn't already specified
|
add( szSound, charsmax(szSound), sndExt ); // Add filetype extension if it isn't already specified
|
||||||
|
}
|
||||||
if ( sndExt[1] == 'w' )
|
if ( sndExt[1] == 'w' )
|
||||||
|
{
|
||||||
format( szSound, charsmax(szSound), "sound/%s", szSound ); // spk basedir is $moddir/sound, but mp3 play is $moddir, fix this for the file_exists check
|
format( szSound, charsmax(szSound), "sound/%s", szSound ); // spk basedir is $moddir/sound, but mp3 play is $moddir, fix this for the file_exists check
|
||||||
|
}
|
||||||
if ( file_exists( szSound ) )
|
if ( file_exists( szSound ) )
|
||||||
{
|
{
|
||||||
if ( sndExt[1] == 'm')
|
if ( sndExt[1] == 'm')
|
||||||
|
@ -173,7 +186,7 @@ public plugin_precache( )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
line++
|
line++;
|
||||||
}
|
}
|
||||||
fclose( fp ); // Close file
|
fclose( fp ); // Close file
|
||||||
return line;
|
return line;
|
||||||
|
@ -186,12 +199,18 @@ public actionCmdMenu(id, key)
|
||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case 8: displayCmdMenu(id, ++g_menuPosition[id])
|
case 8:
|
||||||
case 9: displayCmdMenu(id, --g_menuPosition[id])
|
{
|
||||||
|
displayCmdMenu(id, ++g_menuPosition[id]);
|
||||||
|
}
|
||||||
|
case 9:
|
||||||
|
{
|
||||||
|
displayCmdMenu(id, --g_menuPosition[id]);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
new option = g_menuSelect[id][g_menuPosition[id] * 8 + key]
|
new option = g_menuSelect[id][g_menuPosition[id] * 8 + key];
|
||||||
new flags = g_cmdMisc[option][1]
|
new flags = g_cmdMisc[option][1];
|
||||||
|
|
||||||
if (flags & 1)
|
if (flags & 1)
|
||||||
server_cmd("%s", g_cmdCmd[option])
|
server_cmd("%s", g_cmdCmd[option])
|
||||||
|
@ -201,113 +220,138 @@ public actionCmdMenu(id, key)
|
||||||
client_cmd(0, "%s", g_cmdCmd[option])
|
client_cmd(0, "%s", g_cmdCmd[option])
|
||||||
|
|
||||||
if (flags & 8)
|
if (flags & 8)
|
||||||
displayCmdMenu(id, g_menuPosition[id])
|
{
|
||||||
|
displayCmdMenu(id, g_menuPosition[id]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return PLUGIN_HANDLED
|
return PLUGIN_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
displayCmdMenu(id, pos)
|
displayCmdMenu(id, pos)
|
||||||
{
|
{
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
return
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
new menuBody[512]
|
new menuBody[512];
|
||||||
new b = 0
|
new b = 0;
|
||||||
new start = pos * 8
|
new start = pos * 8;
|
||||||
|
|
||||||
if (start >= g_menuSelectNum[id])
|
if (start >= g_menuSelectNum[id])
|
||||||
start = pos = g_menuPosition[id] = 0
|
{
|
||||||
|
start = pos = g_menuPosition[id] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
new limit = (g_menuSelectNum[id] / 8 + ((g_menuSelectNum[id] % 8)))
|
new limit = (g_menuSelectNum[id] / 8 + ((g_menuSelectNum[id] % 8)));
|
||||||
new len = format(menuBody, charsmax(menuBody), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, g_cmdMenuName[g_menuLayer[id]], pos + 1, (limit == 0) ? 1 : limit)
|
new len = formatex(menuBody, charsmax(menuBody), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, g_cmdMenuName[g_menuLayer[id]], pos + 1, (limit == 0) ? 1 : limit);
|
||||||
new end = start + 8
|
new end = start + 8;
|
||||||
new keys = MENU_KEY_0
|
new keys = MENU_KEY_0;
|
||||||
|
|
||||||
if (end > g_menuSelectNum[id])
|
if (end > g_menuSelectNum[id])
|
||||||
end = g_menuSelectNum[id]
|
{
|
||||||
|
end = g_menuSelectNum[id];
|
||||||
|
}
|
||||||
|
|
||||||
for (new a = start; a < end; ++a)
|
for (new a = start; a < end; ++a)
|
||||||
{
|
{
|
||||||
if (g_cmdCmd[g_menuSelect[id][a]][0] == '-')
|
if (g_cmdCmd[g_menuSelect[id][a]][0] == '-')
|
||||||
{
|
{
|
||||||
if (g_coloredMenus)
|
if (g_coloredMenus)
|
||||||
len += format(menuBody[len], charsmax(menuBody) - len, "\d%s^n\w", g_cmdName[g_menuSelect[id][a]])
|
{
|
||||||
|
len += formatex(menuBody[len], charsmax(menuBody) - len, "\d%s^n\w", g_cmdName[g_menuSelect[id][a]]);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
len += format(menuBody[len], charsmax(menuBody) - len, "%s^n", g_cmdName[g_menuSelect[id][a]])
|
{
|
||||||
++b
|
len += formatex(menuBody[len], charsmax(menuBody) - len, "%s^n", g_cmdName[g_menuSelect[id][a]]);
|
||||||
} else {
|
}
|
||||||
keys |= (1<<b)
|
++b;
|
||||||
len += format(menuBody[len], charsmax(menuBody) - len, "%d. %s^n", ++b, g_cmdName[g_menuSelect[id][a]])
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
keys |= (1<<b);
|
||||||
|
len += formatex(menuBody[len], charsmax(menuBody) - len, "%d. %s^n", ++b, g_cmdName[g_menuSelect[id][a]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end != g_menuSelectNum[id])
|
if (end != g_menuSelectNum[id])
|
||||||
{
|
{
|
||||||
format(menuBody[len], charsmax(menuBody) - len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
|
formatex(menuBody[len], charsmax(menuBody) - len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT");
|
||||||
keys |= MENU_KEY_9
|
keys |= MENU_KEY_9;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
format(menuBody[len], charsmax(menuBody) - len, "^n0. %L", id, pos ? "BACK" : "EXIT")
|
{
|
||||||
|
formatex(menuBody[len], charsmax(menuBody) - len, "^n0. %L", id, pos ? "BACK" : "EXIT");
|
||||||
|
}
|
||||||
|
|
||||||
new MenuName[64]
|
new MenuName[64];
|
||||||
|
|
||||||
format(MenuName, charsmax(MenuName), "%L", "en", g_cmdMenuName[g_menuLayer[id]])
|
formatex(MenuName, charsmax(MenuName), "%L", "en", g_cmdMenuName[g_menuLayer[id]]);
|
||||||
show_menu(id, keys, menuBody, -1, MenuName)
|
show_menu(id, keys, menuBody, -1, MenuName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public cmdCmdMenu(id, level, cid)
|
public cmdCmdMenu(id, level, cid)
|
||||||
{
|
{
|
||||||
if (!cmd_access(id, level, cid, 1))
|
if (!cmd_access(id, level, cid, 1))
|
||||||
return PLUGIN_HANDLED
|
{
|
||||||
|
return PLUGIN_HANDLED;
|
||||||
|
}
|
||||||
|
|
||||||
new szCmd[32]
|
new szCmd[32];
|
||||||
read_argv(0, szCmd, charsmax(szCmd))
|
read_argv(0, szCmd, charsmax(szCmd));
|
||||||
new lvl = 0
|
new lvl = 0;
|
||||||
|
|
||||||
while (lvl < MAX_CMDS_LAYERS)
|
while (lvl < MAX_CMDS_LAYERS)
|
||||||
{
|
{
|
||||||
if (equal(g_cmdMenuCmd[lvl], szCmd))
|
if (equal(g_cmdMenuCmd[lvl], szCmd))
|
||||||
break
|
{
|
||||||
++lvl
|
break;
|
||||||
|
}
|
||||||
|
++lvl;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_menuLayer[id] = lvl
|
g_menuLayer[id] = lvl;
|
||||||
g_menuSelectNum[id] = 0
|
g_menuSelectNum[id] = 0;
|
||||||
|
|
||||||
new a = lvl * MAX_CMDS
|
new a = lvl * MAX_CMDS;
|
||||||
new d, c = 0
|
new d, c = 0;
|
||||||
|
|
||||||
while (c < g_cmdNum[lvl])
|
while (c < g_cmdNum[lvl])
|
||||||
{
|
{
|
||||||
d = a + c
|
d = a + c;
|
||||||
|
|
||||||
if (access(id, g_cmdMisc[d][0]))
|
if (access(id, g_cmdMisc[d][0]))
|
||||||
{
|
{
|
||||||
g_menuSelect[id][g_menuSelectNum[id]++] = d
|
g_menuSelect[id][g_menuSelectNum[id]++] = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
++c
|
++c;
|
||||||
}
|
}
|
||||||
|
|
||||||
displayCmdMenu(id, g_menuPosition[id] = 0)
|
displayCmdMenu(id, g_menuPosition[id] = 0);
|
||||||
|
|
||||||
return PLUGIN_HANDLED
|
return PLUGIN_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadCmdSettings(szFilename[], level)
|
loadCmdSettings(szFilename[], level)
|
||||||
{
|
{
|
||||||
if (!file_exists(szFilename))
|
if (!file_exists(szFilename))
|
||||||
return 0
|
|
||||||
|
|
||||||
new text[256], szFlags[32], szAccess[32]
|
|
||||||
new a, pos = 0, c, d = level * MAX_CMDS
|
|
||||||
|
|
||||||
while (g_cmdNum[level] < MAX_CMDS && read_file(szFilename, pos++, text, 255, a))
|
|
||||||
{
|
{
|
||||||
if (text[0] == ';') continue
|
return 0;
|
||||||
c = d + g_cmdNum[level]
|
}
|
||||||
|
|
||||||
|
new text[256], szFlags[32], szAccess[32];
|
||||||
|
new a, pos = 0, c, d = level * MAX_CMDS;
|
||||||
|
|
||||||
|
while (g_cmdNum[level] < MAX_CMDS && read_file(szFilename, pos++, text, charsmax(text), a))
|
||||||
|
{
|
||||||
|
if (text[0] == ';')
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
c = d + g_cmdNum[level];
|
||||||
|
|
||||||
if (parse(text, g_cmdName[c], charsmax(g_cmdName[]), g_cmdCmd[c], charsmax(g_cmdCmd[]), szFlags, charsmax(szFlags), szAccess, charsmax(szAccess)) > 3)
|
if (parse(text, g_cmdName[c], charsmax(g_cmdName[]), g_cmdCmd[c], charsmax(g_cmdCmd[]), szFlags, charsmax(szFlags), szAccess, charsmax(szAccess)) > 3)
|
||||||
{
|
{
|
||||||
|
@ -316,13 +360,13 @@ loadCmdSettings(szFilename[], level)
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
g_cmdMisc[c][1] = read_flags(szFlags)
|
g_cmdMisc[c][1] = read_flags(szFlags);
|
||||||
g_cmdMisc[c][0] = read_flags(szAccess)
|
g_cmdMisc[c][0] = read_flags(szAccess);
|
||||||
g_cmdNum[level]++
|
g_cmdNum[level]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cvars menu */
|
/* Cvars menu */
|
||||||
|
@ -331,17 +375,23 @@ public actionCvarMenu(id, key)
|
||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case 8: displayCvarMenu(id, ++g_menuPosition[id])
|
case 8:
|
||||||
case 9: displayCvarMenu(id, --g_menuPosition[id])
|
{
|
||||||
|
displayCvarMenu(id, ++g_menuPosition[id]);
|
||||||
|
}
|
||||||
|
case 9:
|
||||||
|
{
|
||||||
|
displayCvarMenu(id, --g_menuPosition[id]);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
new option = g_menuSelect[id][g_menuPosition[id] * 8 + key]
|
new option = g_menuSelect[id][g_menuPosition[id] * 8 + key];
|
||||||
new szValue[32]
|
new szValue[32];
|
||||||
|
|
||||||
get_cvar_string(g_cvarNames[option], szValue, charsmax(szValue))
|
get_cvar_string(g_cvarNames[option], szValue, charsmax(szValue));
|
||||||
|
|
||||||
new end = g_cvarMisc[option][2]
|
new end = g_cvarMisc[option][2];
|
||||||
new start = g_cvarMisc[option][1]
|
new start = g_cvarMisc[option][1];
|
||||||
|
|
||||||
for (new i = start; ; ++i)
|
for (new i = start; ; ++i)
|
||||||
{
|
{
|
||||||
|
@ -351,97 +401,122 @@ public actionCvarMenu(id, key)
|
||||||
{
|
{
|
||||||
if (++i >= end)
|
if (++i >= end)
|
||||||
{
|
{
|
||||||
i = start
|
i = start;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_cvar_string(g_cvarNames[option], g_cvarCmd[i])
|
set_cvar_string(g_cvarNames[option], g_cvarCmd[i]);
|
||||||
break
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
set_cvar_string(g_cvarNames[option], g_cvarCmd[start])
|
else
|
||||||
break
|
{
|
||||||
|
set_cvar_string(g_cvarNames[option], g_cvarCmd[start]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
displayCvarMenu(id, g_menuPosition[id])
|
displayCvarMenu(id, g_menuPosition[id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return PLUGIN_HANDLED
|
return PLUGIN_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
displayCvarMenu(id, pos)
|
displayCvarMenu(id, pos)
|
||||||
{
|
{
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
return
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
new menuBody[512]
|
new menuBody[512];
|
||||||
new b = 0
|
new b = 0;
|
||||||
new start = pos * 8
|
new start = pos * 8;
|
||||||
|
|
||||||
if (start >= g_menuSelectNum[id])
|
if (start >= g_menuSelectNum[id])
|
||||||
start = pos = g_menuPosition[id] = 0
|
{
|
||||||
|
start = pos = g_menuPosition[id] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
new len = format(menuBody, charsmax(menuBody), g_coloredMenus ? "\yCvars Menu\R%d/%d^n\w^n" : "Cvars Menu %d/%d^n^n", pos + 1, (g_menuSelectNum[id] / 8 + ((g_menuSelectNum[id] % 8) ? 1 : 0)))
|
new len = formatex(menuBody, charsmax(menuBody), g_coloredMenus ? "\yCvars Menu\R%d/%d^n\w^n" : "Cvars Menu %d/%d^n^n", pos + 1, (g_menuSelectNum[id] / 8 + ((g_menuSelectNum[id] % 8) ? 1 : 0)));
|
||||||
|
|
||||||
new end = start + 8
|
new end = start + 8;
|
||||||
new keys = MENU_KEY_0
|
new keys = MENU_KEY_0;
|
||||||
new szValue[64]
|
new szValue[64];
|
||||||
|
|
||||||
if (end > g_menuSelectNum[id])
|
if (end > g_menuSelectNum[id])
|
||||||
end = g_menuSelectNum[id]
|
{
|
||||||
|
end = g_menuSelectNum[id];
|
||||||
|
}
|
||||||
|
|
||||||
for (new a = start; a < end; ++a)
|
for (new a = start; a < end; ++a)
|
||||||
{
|
{
|
||||||
get_cvar_string(g_cvarNames[g_menuSelect[id][a]], szValue, charsmax(szValue))
|
get_cvar_string(g_cvarNames[g_menuSelect[id][a]], szValue, charsmax(szValue));
|
||||||
keys |= (1<<b)
|
keys |= (1<<b);
|
||||||
++b
|
++b;
|
||||||
|
|
||||||
if (g_coloredMenus)
|
if (g_coloredMenus)
|
||||||
len += format(menuBody[len], charsmax(menuBody) - len, "%d. %s\R%s^n\w", b, g_cvarNames[g_menuSelect[id][a]], szValue)
|
{
|
||||||
|
len += formatex(menuBody[len], charsmax(menuBody) - len, "%d. %s\R%s^n\w", b, g_cvarNames[g_menuSelect[id][a]], szValue);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
len += format(menuBody[len], charsmax(menuBody) - len, "%d. %s %s^n", b, g_cvarNames[g_menuSelect[id][a]], szValue)
|
{
|
||||||
|
len += formatex(menuBody[len], charsmax(menuBody) - len, "%d. %s %s^n", b, g_cvarNames[g_menuSelect[id][a]], szValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end != g_menuSelectNum[id])
|
if (end != g_menuSelectNum[id])
|
||||||
{
|
{
|
||||||
format(menuBody[len], charsmax(menuBody) - len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
|
formatex(menuBody[len], charsmax(menuBody) - len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT");
|
||||||
keys |= MENU_KEY_9
|
keys |= MENU_KEY_9;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
format(menuBody[len], charsmax(menuBody) - len, "^n0. %L", id, pos ? "BACK" : "EXIT")
|
{
|
||||||
|
formatex(menuBody[len], charsmax(menuBody) - len, "^n0. %L", id, pos ? "BACK" : "EXIT");
|
||||||
|
}
|
||||||
|
|
||||||
show_menu(id, keys, menuBody)
|
show_menu(id, keys, menuBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
public cmdCvarMenu(id, level, cid)
|
public cmdCvarMenu(id, level, cid)
|
||||||
{
|
{
|
||||||
if (!cmd_access(id, level, cid, 1))
|
if (!cmd_access(id, level, cid, 1))
|
||||||
return PLUGIN_HANDLED
|
{
|
||||||
|
return PLUGIN_HANDLED;
|
||||||
|
}
|
||||||
|
|
||||||
g_menuSelectNum[id] = 0
|
g_menuSelectNum[id] = 0;
|
||||||
|
|
||||||
for (new a = 0; a < g_cvarNum; ++a)
|
for (new a = 0; a < g_cvarNum; ++a)
|
||||||
|
{
|
||||||
if (access(id, g_cvarMisc[a][0]))
|
if (access(id, g_cvarMisc[a][0]))
|
||||||
g_menuSelect[id][g_menuSelectNum[id]++] = a
|
{
|
||||||
|
g_menuSelect[id][g_menuSelectNum[id]++] = a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
displayCvarMenu(id, g_menuPosition[id] = 0)
|
displayCvarMenu(id, g_menuPosition[id] = 0);
|
||||||
|
|
||||||
return PLUGIN_HANDLED
|
return PLUGIN_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadCvarSettings(szFilename[])
|
loadCvarSettings(szFilename[])
|
||||||
{
|
{
|
||||||
if (!file_exists(szFilename))
|
if (!file_exists(szFilename))
|
||||||
return 0
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
new text[256], szValues[12][32]
|
new text[256], szValues[12][32];
|
||||||
new inum, a, pos = 0
|
new inum, a, pos = 0;
|
||||||
new cvar_values = MAX_CVARS * 5
|
new cvar_values = MAX_CVARS * 5;
|
||||||
|
|
||||||
// a b c d
|
// a b c d
|
||||||
while (g_cvarNum < MAX_CVARS && read_file(szFilename, pos++, text, charsmax(text), a))
|
while (g_cvarNum < MAX_CVARS && read_file(szFilename, pos++, text, charsmax(text), a))
|
||||||
{
|
{
|
||||||
if (text[0] == ';') continue
|
if (text[0] == ';')
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
inum = parse(text, g_cvarNames[g_cvarNum], charsmax(g_cvarNames[]),
|
inum = parse(text, g_cvarNames[g_cvarNum], charsmax(g_cvarNames[]),
|
||||||
szValues[0], charsmax(szValues[]),
|
szValues[0], charsmax(szValues[]),
|
||||||
|
@ -455,11 +530,15 @@ loadCvarSettings(szFilename[])
|
||||||
szValues[8], charsmax(szValues[]),
|
szValues[8], charsmax(szValues[]),
|
||||||
szValues[9], charsmax(szValues[]),
|
szValues[9], charsmax(szValues[]),
|
||||||
szValues[10], charsmax(szValues[]),
|
szValues[10], charsmax(szValues[]),
|
||||||
szValues[11], charsmax(szValues[]))
|
szValues[11], charsmax(szValues[]));
|
||||||
|
|
||||||
inum -= 2
|
inum -= 2;
|
||||||
if (inum < 2) continue
|
if (inum < 2)
|
||||||
g_cvarMisc[g_cvarNum][1] = g_cvarCmdNum
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_cvarMisc[g_cvarNum][1] = g_cvarCmdNum;
|
||||||
|
|
||||||
for (a = 0; a < inum && g_cvarCmdNum < cvar_values; ++a)
|
for (a = 0; a < inum && g_cvarCmdNum < cvar_values; ++a)
|
||||||
{
|
{
|
||||||
|
@ -468,14 +547,14 @@ loadCvarSettings(szFilename[])
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
copy(g_cvarCmd[g_cvarCmdNum], charsmax(g_cvarCmd[]), szValues[a])
|
copy(g_cvarCmd[g_cvarCmdNum], charsmax(g_cvarCmd[]), szValues[a]);
|
||||||
g_cvarCmdNum++
|
g_cvarCmdNum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_cvarMisc[g_cvarNum][2] = g_cvarCmdNum
|
g_cvarMisc[g_cvarNum][2] = g_cvarCmdNum;
|
||||||
g_cvarMisc[g_cvarNum][0] = read_flags(szValues[inum])
|
g_cvarMisc[g_cvarNum][0] = read_flags(szValues[inum]);
|
||||||
g_cvarNum++
|
g_cvarNum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user