2014-08-04 16:12:15 +04:00
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Commands Menu Plugin
//
2004-01-31 23:56:22 +03:00
2004-03-05 22:35:38 +03:00
# include <amxmodx>
2004-03-07 17:30:53 +03:00
# include <amxmisc>
2004-01-31 23:56:22 +03:00
2007-10-17 00:59:57 +04:00
// Precache sounds from speech.ini - comment this line to disable
# define PRECACHE_SPEECHINI
2004-01-31 23:56:22 +03:00
/* Commands Menus */
# define MAX_CMDS_LAYERS 3
2005-09-13 01:06:24 +04:00
new g_cmdMenuName [ MAX_CMDS_LAYERS ] [ ] =
{
" CMD_MENU " ,
" CONF_MENU " ,
" SPE_MENU "
2015-05-05 19:58:20 +03:00
} ;
2004-01-31 23:56:22 +03:00
2005-09-13 01:06:24 +04:00
new g_cmdMenuCmd [ MAX_CMDS_LAYERS ] [ ] =
{
" amx_cmdmenu " ,
" amx_cfgmenu " ,
" amx_speechmenu "
2015-05-05 19:58:20 +03:00
} ;
2004-01-31 23:56:22 +03:00
2005-09-13 01:06:24 +04:00
new g_cmdMenuCfg [ MAX_CMDS_LAYERS ] [ ] =
{
" cmds.ini " ,
" configs.ini " ,
" speech.ini "
2015-05-05 19:58:20 +03:00
} ;
2004-01-31 23:56:22 +03:00
2005-09-13 01:06:24 +04:00
new g_cmdMenuHelp [ MAX_CMDS_LAYERS ] [ ] =
{
" - displays commands menu " ,
" - displays configs menu " ,
" - displays speech menu "
2015-05-05 19:58:20 +03:00
} ;
2004-01-31 23:56:22 +03:00
/* End of Commands Menu */
2013-02-13 12:09:34 +04:00
# define MAX_CMDS 64
2004-09-01 01:59:09 +04:00
# define MAX_CVARS 48
2004-01-31 23:56:22 +03:00
2015-05-05 19:58:20 +03:00
new g_cmdName [ MAX_CMDS * MAX_CMDS_LAYERS ] [ 32 ] ;
new g_cmdCmd [ MAX_CMDS * MAX_CMDS_LAYERS ] [ 64 ] ;
new g_cmdMisc [ MAX_CMDS * MAX_CMDS_LAYERS ] [ 2 ] ;
new g_cmdNum [ MAX_CMDS_LAYERS ] ;
2004-01-31 23:56:22 +03:00
2015-05-05 19:58:20 +03:00
new g_cvarNames [ MAX_CVARS ] [ 32 ] ;
new g_cvarMisc [ MAX_CVARS ] [ 3 ] ;
new g_cvarCmd [ MAX_CVARS * 5 ] [ 32 ] ;
new g_cvarCmdNum ;
new g_cvarNum ;
2004-01-31 23:56:22 +03:00
2015-05-05 19:58:20 +03:00
new g_menuPosition [ MAX_PLAYERS + 1 ] ;
new g_menuSelect [ MAX_PLAYERS + 1 ] [ MAX_CMDS ] ;
new g_menuSelectNum [ MAX_PLAYERS + 1 ] ;
new g_menuLayer [ MAX_PLAYERS + 1 ] ;
2004-01-31 23:56:22 +03:00
2015-05-05 19:58:20 +03:00
new g_coloredMenus ;
2004-01-31 23:56:22 +03:00
2007-05-24 21:11:11 +04:00
2005-09-13 01:06:24 +04:00
public plugin_init ( )
{
2015-05-05 19:58:20 +03:00
register_plugin ( " Commands Menu " , AMXX_VERSION_STR , " AMXX Dev Team " ) ;
register_dictionary ( " cmdmenu.txt " ) ;
register_dictionary ( " common.txt " ) ;
2005-09-13 01:06:24 +04:00
2015-05-05 19:58:20 +03:00
new configsDir [ 64 ] , config [ 64 ] ;
get_configsdir ( configsDir , charsmax ( configsDir ) ) ;
2005-09-13 01:06:24 +04:00
for ( new a = 0 ; a < MAX_CMDS_LAYERS ; + + a )
{
2015-05-05 19:58:20 +03:00
new MenuName [ 64 ] ;
2005-09-13 01:06:24 +04:00
2015-05-05 19:58:20 +03:00
formatex ( MenuName , charsmax ( MenuName ) , " %L " , " en " , g_cmdMenuName [ a ] ) ;
register_menucmd ( register_menuid ( MenuName ) , 1023 , " actionCmdMenu " ) ;
register_clcmd ( g_cmdMenuCmd [ a ] , " cmdCmdMenu " , ADMIN_MENU , g_cmdMenuHelp [ a ] ) ;
formatex ( config , charsmax ( config ) , " %s/%s " , configsDir , g_cmdMenuCfg [ a ] ) ;
loadCmdSettings ( config , a ) ;
2005-09-13 01:06:24 +04:00
}
2015-05-05 19:58:20 +03:00
register_menucmd ( register_menuid ( " Cvars Menu " ) , 1023 , " actionCvarMenu " ) ;
register_clcmd ( " amx_cvarmenu " , " cmdCvarMenu " , ADMIN_CVAR , " - displays cvars menu " ) ;
2005-09-13 01:06:24 +04:00
new cvars_ini_file [ 64 ] ;
2015-05-05 19:58:20 +03:00
formatex ( cvars_ini_file , charsmax ( cvars_ini_file ) , " %s/%s " , configsDir , " cvars.ini " ) ;
loadCvarSettings ( cvars_ini_file ) ;
2005-09-13 01:06:24 +04:00
2015-05-05 19:58:20 +03:00
g_coloredMenus = colored_menus ( ) ;
2004-01-31 23:56:22 +03:00
}
2007-10-17 00:59:57 +04:00
# if defined PRECACHE_SPEECHINI
public plugin_precache ( )
{
new configsDir [ 64 ] , config [ 64 ] ;
2014-07-29 18:32:32 +04:00
get_configsdir ( configsDir , charsmax ( configsDir ) ) ;
formatex ( config , charsmax ( config ) , " %s/%s " , configsDir , " speech.ini " ) ;
2007-10-17 00:59:57 +04:00
new fp = fopen ( config , " rt " ) ; // Read file as text
if ( ! fp ) // File doesn't exists
2015-05-05 19:58:20 +03:00
{
2007-10-17 00:59:57 +04:00
return 0 ;
2015-05-05 19:58:20 +03:00
}
2007-10-17 00:59:57 +04:00
new szText [ 256 ] ;
new line = 0 ;
new szName [ 32 ] , szSound [ 128 ] , sndExt [ 5 ] ;
new field1 [ 32 ] , field2 [ 64 ] , field3 [ 64 ] ;
new fieldNums = 0 ;
2015-05-05 19:58:20 +03:00
new const voxIdent [ ] = " vox " , fvoxIdent [ ] = " fvox " , barneyIdent [ ] = " barney " , hgruntIdent [ ] = " hgrunt " ;
2007-10-17 00:59:57 +04:00
2021-08-07 18:28:35 +03:00
while ( line < MAX_CMDS & & fgets ( fp , szText , charsmax ( szText ) ) ) // Loop till MAX_CMDS or no more file data
2007-10-17 00:59:57 +04:00
{
/* Strips newline */
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
2015-05-05 19:58:20 +03:00
{
2007-10-17 00:59:57 +04:00
szText [ - - len ] = 0 ;
2015-05-05 19:58:20 +03:00
}
2007-10-17 00:59:57 +04:00
if ( len = = 0 | | szText [ 0 ] = = ';' | | szText [ 0 ] = = '/' ) // Line is empty or a comment
2015-05-05 19:58:20 +03:00
{
2007-10-17 00:59:57 +04:00
continue ;
2015-05-05 19:58:20 +03:00
}
2007-10-17 00:59:57 +04:00
2014-07-29 18:32:32 +04:00
parse ( szText , szName , charsmax ( szName ) , szSound , charsmax ( szSound ) ) ;
fieldNums = parse ( szSound , field1 , charsmax ( field1 ) , field2 , charsmax ( field2 ) , field3 , charsmax ( field3 ) ) ;
2007-10-17 00:59:57 +04:00
if ( fieldNums = = 2 & & field1 [ 0 ] = = 's' ) // .wav (spk)
{
2014-07-29 18:32:32 +04:00
copy ( szSound , charsmax ( szSound ) , field2 ) ;
copy ( sndExt , charsmax ( sndExt ) , " .wav " ) ;
2007-10-17 00:59:57 +04:00
}
else if ( fieldNums = = 3 & & field1 [ 0 ] = = 'm' & & ( field2 [ 0 ] = = 'p' | | field2 [ 0 ] = = 'l' ) ) // .mp3 (mp3 play | mp3 loop)
{
2014-07-29 18:32:32 +04:00
copy ( szSound , charsmax ( szSound ) , field3 ) ;
copy ( sndExt , charsmax ( sndExt ) , " .mp3 " ) ;
2007-10-17 00:59:57 +04:00
}
else // WTH is this sound, drop it.
continue ;
2014-07-29 18:32:32 +04:00
replace_all ( szSound , charsmax ( szSound ) , " \' " , " " ) ; // Strips all ugly (and sometimes useless) \'
2007-10-17 00:59:57 +04:00
if ( szSound [ 0 ] = = '/' )
2015-05-05 19:58:20 +03:00
{
2014-07-29 18:32:32 +04:00
replace ( szSound , charsmax ( szSound ) , " / " , " " ) ; // Strip leading slash
2015-05-05 19:58:20 +03:00
}
2007-10-17 00:59:57 +04:00
2015-05-05 19:58:20 +03:00
if ( sndExt [ 1 ] = = 'm' | | ( ! equali ( szSound , voxIdent , charsmax ( voxIdent ) ) & & ! equali ( szSound , fvoxIdent , charsmax ( fvoxIdent ) ) & & ! equali ( szSound , barneyIdent , charsmax ( barneyIdent ) ) & & ! equali ( szSound , hgruntIdent , charsmax ( hgruntIdent ) ) ) )
2007-10-17 00:59:57 +04:00
{
// 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 ) )
2015-05-05 19:58:20 +03:00
{
2014-07-29 18:32:32 +04:00
add ( szSound , charsmax ( szSound ) , sndExt ) ; // Add filetype extension if it isn't already specified
2015-05-05 19:58:20 +03:00
}
2007-10-17 00:59:57 +04:00
if ( sndExt [ 1 ] = = 'w' )
2015-05-05 19:58:20 +03:00
{
2014-07-29 18:32:32 +04:00
format ( szSound , charsmax ( szSound ) , " sound/%s " , szSound ) ; // spk basedir is $moddir/sound, but mp3 play is $moddir, fix this for the file_exists check
2015-05-05 19:58:20 +03:00
}
2007-10-17 00:59:57 +04:00
if ( file_exists ( szSound ) )
{
2021-09-17 14:10:46 +03:00
precache_generic ( szSound ) ;
2007-10-17 00:59:57 +04:00
}
}
2015-05-05 19:58:20 +03:00
line + + ;
2007-10-17 00:59:57 +04:00
}
fclose ( fp ) ; // Close file
return line ;
}
# endif
2004-01-31 23:56:22 +03:00
/* Commands menu */
2005-09-13 01:06:24 +04:00
public actionCmdMenu ( id , key )
{
switch ( key )
{
2015-05-05 19:58:20 +03:00
case 8 :
{
displayCmdMenu ( id , + + g_menuPosition [ id ] ) ;
}
case 9 :
{
displayCmdMenu ( id , - - g_menuPosition [ id ] ) ;
}
2005-09-13 01:06:24 +04:00
default :
{
2015-05-05 19:58:20 +03:00
new option = g_menuSelect [ id ] [ g_menuPosition [ id ] * 8 + key ] ;
new flags = g_cmdMisc [ option ] [ 1 ] ;
2005-09-13 01:06:24 +04:00
if ( flags & 1 )
2005-11-21 23:31:18 +03:00
server_cmd ( " %s " , g_cmdCmd [ option ] )
2005-09-13 01:06:24 +04:00
else if ( flags & 2 )
2005-11-21 23:31:18 +03:00
client_cmd ( id , " %s " , g_cmdCmd [ option ] )
2005-09-13 01:06:24 +04:00
else if ( flags & 4 )
2005-11-21 23:31:18 +03:00
client_cmd ( 0 , " %s " , g_cmdCmd [ option ] )
2005-09-13 01:06:24 +04:00
if ( flags & 8 )
2015-05-05 19:58:20 +03:00
{
displayCmdMenu ( id , g_menuPosition [ id ] ) ;
}
2005-09-13 01:06:24 +04:00
}
}
2015-05-05 19:58:20 +03:00
return PLUGIN_HANDLED ;
2004-01-31 23:56:22 +03:00
}
2005-09-13 01:06:24 +04:00
displayCmdMenu ( id , pos )
{
if ( pos < 0 )
2015-05-05 19:58:20 +03:00
{
return ;
}
2005-09-13 01:06:24 +04:00
2015-05-05 19:58:20 +03:00
new menuBody [ 512 ] ;
new b = 0 ;
new start = pos * 8 ;
2005-09-13 01:06:24 +04:00
if ( start > = g_menuSelectNum [ id ] )
2015-05-05 19:58:20 +03:00
{
start = pos = g_menuPosition [ id ] = 0 ;
}
2007-01-02 16:17:33 +03:00
2015-05-05 19:58:20 +03:00
new limit = ( g_menuSelectNum [ id ] / 8 + ( ( g_menuSelectNum [ id ] % 8 ) ) ) ;
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 keys = MENU_KEY_0 ;
2005-09-13 01:06:24 +04:00
if ( end > g_menuSelectNum [ id ] )
2015-05-05 19:58:20 +03:00
{
end = g_menuSelectNum [ id ] ;
}
2005-09-13 01:06:24 +04:00
for ( new a = start ; a < end ; + + a )
{
if ( g_cmdCmd [ g_menuSelect [ id ] [ a ] ] [ 0 ] = = '-' )
{
if ( g_coloredMenus )
2015-05-05 19:58:20 +03:00
{
len + = formatex ( menuBody [ len ] , charsmax ( menuBody ) - len , " \ d%s^n \ w " , g_cmdName [ g_menuSelect [ id ] [ a ] ] ) ;
}
2005-09-13 01:06:24 +04:00
else
2015-05-05 19:58:20 +03:00
{
len + = formatex ( menuBody [ len ] , charsmax ( menuBody ) - len , " %s^n " , g_cmdName [ g_menuSelect [ id ] [ a ] ] ) ;
}
+ + b ;
}
else
{
keys | = ( 1 < < b ) ;
len + = formatex ( menuBody [ len ] , charsmax ( menuBody ) - len , " %d. %s^n " , + + b , g_cmdName [ g_menuSelect [ id ] [ a ] ] ) ;
2005-09-13 01:06:24 +04:00
}
}
if ( end ! = g_menuSelectNum [ id ] )
{
2015-05-05 19:58:20 +03:00
formatex ( menuBody [ len ] , charsmax ( menuBody ) - len , " ^n9. %L...^n0. %L " , id , " MORE " , id , pos ? " BACK " : " EXIT " ) ;
keys | = MENU_KEY_9 ;
2005-09-13 01:06:24 +04:00
}
else
2015-05-05 19:58:20 +03:00
{
formatex ( menuBody [ len ] , charsmax ( menuBody ) - len , " ^n0. %L " , id , pos ? " BACK " : " EXIT " ) ;
}
2005-09-13 01:06:24 +04:00
2015-05-05 19:58:20 +03:00
new MenuName [ 64 ] ;
2005-09-13 01:06:24 +04:00
2015-05-05 19:58:20 +03:00
formatex ( MenuName , charsmax ( MenuName ) , " %L " , " en " , g_cmdMenuName [ g_menuLayer [ id ] ] ) ;
show_menu ( id , keys , menuBody , - 1 , MenuName ) ;
2004-01-31 23:56:22 +03:00
}
2005-09-13 01:06:24 +04:00
public cmdCmdMenu ( id , level , cid )
{
if ( ! cmd_access ( id , level , cid , 1 ) )
2015-05-05 19:58:20 +03:00
{
return PLUGIN_HANDLED ;
}
2005-09-13 01:06:24 +04:00
2015-05-05 19:58:20 +03:00
new szCmd [ 32 ] ;
read_argv ( 0 , szCmd , charsmax ( szCmd ) ) ;
new lvl = 0 ;
2005-09-13 01:06:24 +04:00
while ( lvl < MAX_CMDS_LAYERS )
{
if ( equal ( g_cmdMenuCmd [ lvl ] , szCmd ) )
2015-05-05 19:58:20 +03:00
{
break ;
}
+ + lvl ;
2005-09-13 01:06:24 +04:00
}
2015-05-05 19:58:20 +03:00
g_menuLayer [ id ] = lvl ;
g_menuSelectNum [ id ] = 0 ;
2005-09-13 01:06:24 +04:00
2015-05-05 19:58:20 +03:00
new a = lvl * MAX_CMDS ;
new d , c = 0 ;
2005-09-13 01:06:24 +04:00
while ( c < g_cmdNum [ lvl ] )
{
2015-05-05 19:58:20 +03:00
d = a + c ;
2005-09-13 01:06:24 +04:00
2007-06-22 21:47:32 +04:00
if ( access ( id , g_cmdMisc [ d ] [ 0 ] ) )
2005-09-13 01:06:24 +04:00
{
2015-05-05 19:58:20 +03:00
g_menuSelect [ id ] [ g_menuSelectNum [ id ] + + ] = d ;
2005-09-13 01:06:24 +04:00
}
2015-05-05 19:58:20 +03:00
+ + c ;
2005-09-13 01:06:24 +04:00
}
2015-05-05 19:58:20 +03:00
displayCmdMenu ( id , g_menuPosition [ id ] = 0 ) ;
2005-09-13 01:06:24 +04:00
2015-05-05 19:58:20 +03:00
return PLUGIN_HANDLED ;
2004-01-31 23:56:22 +03:00
}
2005-09-13 01:06:24 +04:00
loadCmdSettings ( szFilename [ ] , level )
{
2015-05-05 19:58:20 +03:00
if ( ! file_exists ( szFilename ) )
{
return 0 ;
}
2005-09-13 01:06:24 +04:00
2015-05-05 19:58:20 +03:00
new text [ 256 ] , szFlags [ 32 ] , szAccess [ 32 ] ;
new a , pos = 0 , c , d = level * MAX_CMDS ;
2005-09-13 01:06:24 +04:00
2015-05-05 19:58:20 +03:00
while ( g_cmdNum [ level ] < MAX_CMDS & & read_file ( szFilename , pos + + , text , charsmax ( text ) , a ) )
2005-09-13 01:06:24 +04:00
{
2015-05-05 19:58:20 +03:00
if ( text [ 0 ] = = ';' )
{
continue ;
}
c = d + g_cmdNum [ level ] ;
2005-09-13 01:06:24 +04:00
2014-07-29 18:32:32 +04:00
if ( parse ( text , g_cmdName [ c ] , charsmax ( g_cmdName [ ] ) , g_cmdCmd [ c ] , charsmax ( g_cmdCmd [ ] ) , szFlags , charsmax ( szFlags ) , szAccess , charsmax ( szAccess ) ) > 3 )
2005-09-13 01:06:24 +04:00
{
2014-07-29 18:32:32 +04:00
while ( replace ( g_cmdCmd [ c ] , charsmax ( g_cmdCmd [ ] ) , " \' " , " ^ " " ))
2005-09-13 01:06:24 +04:00
{
// do nothing
}
2015-05-05 19:58:20 +03:00
g_cmdMisc [ c ] [ 1 ] = read_flags ( szFlags ) ;
g_cmdMisc [ c ] [ 0 ] = read_flags ( szAccess ) ;
g_cmdNum [ level ] + + ;
2005-09-13 01:06:24 +04:00
}
}
2015-05-05 19:58:20 +03:00
return 1 ;
2004-01-31 23:56:22 +03:00
}
/* Cvars menu */
2005-09-13 01:06:24 +04:00
public actionCvarMenu ( id , key )
{
switch ( key )
{
2015-05-05 19:58:20 +03:00
case 8 :
{
displayCvarMenu ( id , + + g_menuPosition [ id ] ) ;
}
case 9 :
{
displayCvarMenu ( id , - - g_menuPosition [ id ] ) ;
}
2005-09-13 01:06:24 +04:00
default :
{
2015-05-05 19:58:20 +03:00
new option = g_menuSelect [ id ] [ g_menuPosition [ id ] * 8 + key ] ;
new szValue [ 32 ] ;
2005-09-13 01:06:24 +04:00
2015-05-05 19:58:20 +03:00
get_cvar_string ( g_cvarNames [ option ] , szValue , charsmax ( szValue ) ) ;
2005-09-13 01:06:24 +04:00
2015-05-05 19:58:20 +03:00
new end = g_cvarMisc [ option ] [ 2 ] ;
new start = g_cvarMisc [ option ] [ 1 ] ;
2005-09-13 01:06:24 +04:00
for ( new i = start ; ; + + i )
{
if ( i < end )
{
if ( equal ( szValue , g_cvarCmd [ i ] ) )
{
if ( + + i > = end )
{
2015-05-05 19:58:20 +03:00
i = start ;
2005-09-13 01:06:24 +04:00
}
2015-05-05 19:58:20 +03:00
set_cvar_string ( g_cvarNames [ option ] , g_cvarCmd [ i ] ) ;
break ;
2005-09-13 01:06:24 +04:00
}
2015-05-05 19:58:20 +03:00
}
else
{
set_cvar_string ( g_cvarNames [ option ] , g_cvarCmd [ start ] ) ;
break ;
2005-09-13 01:06:24 +04:00
}
}
2015-05-05 19:58:20 +03:00
displayCvarMenu ( id , g_menuPosition [ id ] ) ;
2005-09-13 01:06:24 +04:00
}
}
2015-05-05 19:58:20 +03:00
return PLUGIN_HANDLED ;
2004-01-31 23:56:22 +03:00
}
2005-09-13 01:06:24 +04:00
displayCvarMenu ( id , pos )
{
if ( pos < 0 )
2015-05-05 19:58:20 +03:00
{
return ;
}
2005-09-13 01:06:24 +04:00
2015-05-05 19:58:20 +03:00
new menuBody [ 512 ] ;
new b = 0 ;
new start = pos * 8 ;
2005-09-13 01:06:24 +04:00
if ( start > = g_menuSelectNum [ id ] )
2015-05-05 19:58:20 +03:00
{
start = pos = g_menuPosition [ id ] = 0 ;
}
2005-09-13 01:06:24 +04:00
2015-05-05 19:58:20 +03:00
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 ) ) ) ;
2005-09-13 01:06:24 +04:00
2015-05-05 19:58:20 +03:00
new end = start + 8 ;
new keys = MENU_KEY_0 ;
new szValue [ 64 ] ;
2005-09-13 01:06:24 +04:00
if ( end > g_menuSelectNum [ id ] )
2015-05-05 19:58:20 +03:00
{
end = g_menuSelectNum [ id ] ;
}
2005-09-13 01:06:24 +04:00
for ( new a = start ; a < end ; + + a )
{
2015-05-05 19:58:20 +03:00
get_cvar_string ( g_cvarNames [ g_menuSelect [ id ] [ a ] ] , szValue , charsmax ( szValue ) ) ;
keys | = ( 1 < < b ) ;
+ + b ;
2005-09-13 01:06:24 +04:00
if ( g_coloredMenus )
2015-05-05 19:58:20 +03:00
{
len + = formatex ( menuBody [ len ] , charsmax ( menuBody ) - len , " %d. %s \ R%s^n \ w " , b , g_cvarNames [ g_menuSelect [ id ] [ a ] ] , szValue ) ;
}
2005-09-13 01:06:24 +04:00
else
2015-05-05 19:58:20 +03:00
{
len + = formatex ( menuBody [ len ] , charsmax ( menuBody ) - len , " %d. %s %s^n " , b , g_cvarNames [ g_menuSelect [ id ] [ a ] ] , szValue ) ;
}
2005-09-13 01:06:24 +04:00
}
if ( end ! = g_menuSelectNum [ id ] )
{
2015-05-05 19:58:20 +03:00
formatex ( menuBody [ len ] , charsmax ( menuBody ) - len , " ^n9. %L...^n0. %L " , id , " MORE " , id , pos ? " BACK " : " EXIT " ) ;
keys | = MENU_KEY_9 ;
2005-09-13 01:06:24 +04:00
}
else
2015-05-05 19:58:20 +03:00
{
formatex ( menuBody [ len ] , charsmax ( menuBody ) - len , " ^n0. %L " , id , pos ? " BACK " : " EXIT " ) ;
}
2005-09-13 01:06:24 +04:00
2015-05-05 19:58:20 +03:00
show_menu ( id , keys , menuBody ) ;
2005-09-13 01:06:24 +04:00
}
2004-01-31 23:56:22 +03:00
2005-09-13 01:06:24 +04:00
public cmdCvarMenu ( id , level , cid )
{
if ( ! cmd_access ( id , level , cid , 1 ) )
2015-05-05 19:58:20 +03:00
{
return PLUGIN_HANDLED ;
}
2004-08-05 15:09:16 +04:00
2015-05-05 19:58:20 +03:00
g_menuSelectNum [ id ] = 0 ;
2004-08-05 15:09:16 +04:00
2005-09-13 01:06:24 +04:00
for ( new a = 0 ; a < g_cvarNum ; + + a )
2015-05-05 19:58:20 +03:00
{
2007-06-22 21:47:32 +04:00
if ( access ( id , g_cvarMisc [ a ] [ 0 ] ) )
2015-05-05 19:58:20 +03:00
{
g_menuSelect [ id ] [ g_menuSelectNum [ id ] + + ] = a ;
}
}
2004-08-05 15:09:16 +04:00
2015-05-05 19:58:20 +03:00
displayCvarMenu ( id , g_menuPosition [ id ] = 0 ) ;
2004-08-05 15:09:16 +04:00
2015-05-05 19:58:20 +03:00
return PLUGIN_HANDLED ;
2004-01-31 23:56:22 +03:00
}
2005-09-13 01:06:24 +04:00
loadCvarSettings ( szFilename [ ] )
{
if ( ! file_exists ( szFilename ) )
2015-05-05 19:58:20 +03:00
{
return 0 ;
}
2005-09-13 01:06:24 +04:00
2015-05-05 19:58:20 +03:00
new text [ 256 ] , szValues [ 12 ] [ 32 ] ;
new inum , a , pos = 0 ;
new cvar_values = MAX_CVARS * 5 ;
2005-09-13 01:06:24 +04:00
// a b c d
2014-07-29 18:32:32 +04:00
while ( g_cvarNum < MAX_CVARS & & read_file ( szFilename , pos + + , text , charsmax ( text ) , a ) )
2005-09-13 01:06:24 +04:00
{
2015-05-05 19:58:20 +03:00
if ( text [ 0 ] = = ';' )
{
continue ;
}
2005-09-13 01:06:24 +04:00
2014-07-29 18:32:32 +04:00
inum = parse ( text , g_cvarNames [ g_cvarNum ] , charsmax ( g_cvarNames [ ] ) ,
2014-07-30 12:19:41 +04:00
szValues [ 0 ] , charsmax ( szValues [ ] ) ,
szValues [ 1 ] , charsmax ( szValues [ ] ) ,
szValues [ 2 ] , charsmax ( szValues [ ] ) ,
szValues [ 3 ] , charsmax ( szValues [ ] ) ,
szValues [ 4 ] , charsmax ( szValues [ ] ) ,
szValues [ 5 ] , charsmax ( szValues [ ] ) ,
szValues [ 6 ] , charsmax ( szValues [ ] ) ,
szValues [ 7 ] , charsmax ( szValues [ ] ) ,
szValues [ 8 ] , charsmax ( szValues [ ] ) ,
szValues [ 9 ] , charsmax ( szValues [ ] ) ,
szValues [ 10 ] , charsmax ( szValues [ ] ) ,
2015-05-05 19:58:20 +03:00
szValues [ 11 ] , charsmax ( szValues [ ] ) ) ;
2005-09-13 01:06:24 +04:00
2015-05-05 19:58:20 +03:00
inum - = 2 ;
if ( inum < 2 )
{
continue ;
}
g_cvarMisc [ g_cvarNum ] [ 1 ] = g_cvarCmdNum ;
2005-09-13 01:06:24 +04:00
for ( a = 0 ; a < inum & & g_cvarCmdNum < cvar_values ; + + a )
{
2014-07-30 12:19:41 +04:00
while ( replace ( szValues [ a ] , charsmax ( szValues [ ] ) , " \' " , " ^ " " ))
2005-09-13 01:06:24 +04:00
{
// do nothing
}
2015-05-05 19:58:20 +03:00
copy ( g_cvarCmd [ g_cvarCmdNum ] , charsmax ( g_cvarCmd [ ] ) , szValues [ a ] ) ;
g_cvarCmdNum + + ;
2005-09-13 01:06:24 +04:00
}
2015-05-05 19:58:20 +03:00
g_cvarMisc [ g_cvarNum ] [ 2 ] = g_cvarCmdNum ;
g_cvarMisc [ g_cvarNum ] [ 0 ] = read_flags ( szValues [ inum ] ) ;
g_cvarNum + + ;
2005-09-13 01:06:24 +04:00
}
2015-05-05 19:58:20 +03:00
return 1 ;
2004-01-31 23:56:22 +03:00
}