|
发表于 2011-12-6 15:05:18
|
显示全部楼层
来自 中国–广东–深圳–龙岗区
7# ckn911
#include <amxmodx>
#include <amxmisc>
/* Player Menus */
#define MAX_MENU_NUM 40
new g_MenuName[ MAX_MENU_NUM ][32]
new g_MenuCmd[ MAX_MENU_NUM ][32]
new PMenuName[] = "玩家菜单"
new g_MenuItem[3][] = {
"下一页",
"返回",
"退出"
}
new g_cNum
new g_menuPosition[33]
public plugin_init() {
register_plugin("玩家菜单","0.1","nwb13")
register_menucmd(register_menuid( PMenuName ),1023,"actionPlMenu")
register_clcmd("say menu","PlMenu",ADMIN_ALL, "display player menu" )
new configs[64]
get_configsdir(configs, 63)
format(configs, 63, "%s/%s", configs, "plmenu.ini")
loadSettings(configs)
}
loadSettings(plmenuconfig[]) {
if (!file_exists(plmenuconfig))
return 0
new temp[256]
new a, pos = 0
while ( g_cNum < MAX_MENU_NUM && read_file(plmenuconfig,pos++,temp,255,a) ) {
if ( temp[0] == ';' )
continue
if (parse(temp,g_MenuName[g_cNum],31,g_MenuCmd[g_cNum],31) < 2)
continue
++g_cNum
}
return 1
}
public PlMenu(id){
if (is_user_connected(id))
disPlayerMenu(id,g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
disPlayerMenu(id,pos) {
if (pos < 0) return
new menuBody[512]
new b = 0
new start = pos * 8
if (start >= g_cNum )
start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511,"\y%s\R%d/%d^n\w^n",PMenuName,pos+1,( g_cNum / 8 + ((g_cNum % 8) ? 1 : 0 )) )
new end = start + 8
new keys = MENU_KEY_0
if (end > g_cNum )
end = g_cNum
for (new a = start; a < end; ++a) {
keys |= (1<<b)
len += format(menuBody[len],511-len,"\y[\r%d\y]\w %s^n",++b,g_MenuName[a])
}
if (end != g_cNum ) {
format(menuBody[len],511-len,"^n\y[\r9\y]\w %s...^n0. %s", g_MenuItem[0], pos ? g_MenuItem[1] : g_MenuItem[2])
keys |= MENU_KEY_9
}
else format(menuBody[len],511-len,"^n\y[\r0\y]\w %s",pos ? g_MenuItem[1] : g_MenuItem[2])
show_menu(id,keys,menuBody,-1,PMenuName)
}
public actionPlMenu(id,key){
switch(key){
case 8:{
disPlayerMenu(id,++g_menuPosition[id])
}
case 9:{
disPlayerMenu(id,--g_menuPosition[id])
}
default:{
new menuitem = g_menuPosition[id] * 8 + key
client_cmd(id,"%s",g_MenuCmd[menuitem])
}
}
return PLUGIN_HANDLED
} |
|