|
本帖最后由 Zero0senven 于 2011-1-6 09:16 编辑
我的意思是在菜单把配置文件的参数状态显示在菜单上,然后在菜单更改其状态并保存到配置文件中
例如这个..
============================================================
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <regex>
new menu_position[33]
new config_file_plugin[64]
new const AMXMD_CONFIG_PLUGIN[] = "amxmd.cfg"
new config_dir_main[64]
#define AMXMD_ACCESS ADMIN_LEVEL_A
#define NUM_CVARS 22
new cvar_names[NUM_CVARS][] = {
"amx_match_endtype", // 0
"amx_match_hostname", // 1
"amx_match_hltvdelay", // 30
"amx_match_kniferound", // 0
"amx_match_overtime", // 1
"amx_match_otcfg", // 1
"amx_match_otlength", // 3
"amx_match_otunlimited", // 0
"amx_match_password", // 1
"amx_match_password2", // scrim
"amx_match_playerneed", // 10
"amx_match_pugstyle", // 0
"amx_match_randomizeteams", // 0
"amx_match_readytype", // 1
"amx_match_swaptype", // 1
"amx_match_screenshot", // 1
"amx_match_screenshot2", // 1
"amx_match_shield", // 1
"amx_match_shield2", // 1
"amx_match_showscore", // 1
"amx_match_stats", // 0
"amx_match_warmupcfg" // 0
}
new cvar_language[NUM_CVARS][] = {
"END_TYPE", // amx_match_endtype
"CHANGE_HOSTNAME", // amx_match_hostname
"HLTV_DELAY", // amx_match_hltvdelay
"KNIFE_ROUND", // amx_match_kniferound
"ALLOW_OVERTIME", // amx_match_overtime
"OVERTIME_CONFIGS", // amx_match_otcfg
"OVERTIME_LENGTH", // amx_match_otlength
"OVERTIME_UNLIMITED", // amx_match_otunlimited
"CHANGE_PASSWORD", // amx_match_password
"PASSWORD", // amx_match_password2
"NEEDED_READY_PLAYERS", // amx_match_playerneed
"PUG_STYLE", // amx_match_pugstyle
"RANDOMIZE_TEAMS", // amx_match_randomizeteams
"READY_TYPE", // amx_match_readytype
"AUTO_SWAP", // amx_match_swaptype
"SCREEN_SHOT", // amx_match_screenshot
"ALWAYS_SCREENSHOT", // amx_match_screenshot2
"ALLOW_SHIELDS", // amx_match_shield
"REALLOW_SHIELD", // amx_match_shield2
"SHOW_SCORE", // amx_match_showscore
"STATS", // amx_match_stats
"WARMUP_CONFIGS" // amx_match_warmupcfg
}
new cvar_properties[NUM_CVARS][] = {
"0", // amx_match_endtype
"1", // amx_match_hostname
"30", // amx_match_hltvdelay
"0", // amx_match_kniferound
"1", // amx_match_overtime
"1", // amx_match_otcfg
"3", // amx_match_otlength
"0", // amx_match_otunlimited
"1", // amx_match_password
"scrim", // amx_match_password2
"10", // amx_match_playerneed
"0", // amx_match_pugstyle
"0", // amx_match_randomizeteams
"1", // amx_match_readytype
"1", // amx_match_swaptype
"1", // amx_match_screenshot
"1", // amx_match_screenshot2
"1", // amx_match_shield
"1", // amx_match_shield2
"1", // amx_match_showscore
"0", // amx_match_stats
"0" // amx_match_warmupcfg
}
public plugin_precache()
{
register_concmd("amx_matchmenu", "menu_console", AMXMD_ACCESS, " - AMX Match Menu")
}
public plugin_init()
{
register_menucmd(register_menuid("SConfiguration"),1023,"menuactionsettings")
format(config_file_plugin,63,"%s/%s", config_dir_main, AMXMD_CONFIG_PLUGIN)
if (file_exists(config_file_plugin))
{
server_cmd("exec %s", config_file_plugin)
}
for (new i = 0; i < NUM_CVARS; i++)
{
register_cvar(cvar_names, cvar_properties)
}
return PLUGIN_CONTINUE
}
public menu_console(id,level)
{
if (!access(id,level))
{
return PLUGIN_HANDLED
}
menu_show_settings(id)
return PLUGIN_CONTINUE
}
// Plugin Settings Menu
public menu_show_settings(id)
{
new menu_body[1024]
new keys = (1<<7)|(1<<9)
new formatPos = 0
new setting[32]
new cvar_property[32]
new start = menu_position[id] * 7
new end = start + 7
new cvar_name[32]
new cvar_lang[32]
// Format heading
formatPos = format(menu_body, 1023, "\y菜单标题: (%d/%d)^n",menu_position[id] + 1, (NUM_CVARS / 7) + 1 )
// Make sure we don't go off the end of the world
if( end > NUM_CVARS)
{
end = NUM_CVARS
}
new j = 1
for(new i = start; i < end; i++)
{
copy(cvar_name, 31, cvar_names)
copy(cvar_lang, 31, cvar_language)
get_cvar_string(cvar_name, cvar_property, 31)
format(setting, 31, "%L", id, (str_to_num(cvar_property) == 1) ? "ON" : "OFF")
// Format end
if( end == NUM_CVARS)
{
formatPos += format(menu_body[formatPos], 1023 - formatPos, "^n^n\w8. %L^n^n^n^n0. %L", id, "SAVE_CONFIG", id, "BACK")
}
else
{
formatPos += format(menu_body[formatPos],1023 - formatPos,"^n^n\w8. %L^n^n9. %L^n^n0. %L",id, "SAVE_CONFIG", id, "MORE", id, "BACK")
keys |= (1<<8)
}
// show_menu(id, keys, menu_body)
show_menu(id, keys, menu_body, -1, "SConfiguration")
return PLUGIN_CONTINUE
}
public menuactionsettings(id,key)
{
new cvar_number
new cvar_name[32]
if( key <= 6)
{
cvar_number = key + (menu_position[id] * 7)
copy(cvar_name, 31, cvar_names[cvar_number])
}
switch(key) // Main switch
{
case 7: // Save settings
{
client_print(id,print_chat,"* [AMX MATCH] %L ...",id, "SETTINGS_SAVED")
save_settings(config_file_plugin)
menu_show_settings(id)
}
case 8: // Get more
{
menu_position[id]++
menu_show_settings(id)
}
case 9: // Go back
{
if( menu_position[id] == 0 )
{
menu_show_settings(id)
}
else
{
menu_position[id]--
menu_show_settings(id)
}
}
default:
{
set_cvar_num(cvar_name,!(get_cvar_num(cvar_name)))
menu_show_settings(id)
}
}
return PLUGIN_HANDLED
} |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注个册吧
×
|