|
菜单已经建立好。想在另一个函数中获取用户按的数字,代码要如何写?
谢谢
简单代码如下。- include <amxmod>
- public plugin_init()
- {
- register_menucmd(register_menuid("\y菜单标题:"), 1023, "MenuCommand" )
- return PLUGIN_CONTINUE
- }
- public ShowMenu( id )
- {
- new szMenuBody[256]
- new keys
- new nLen = format( szMenuBody, 255, "\y菜单标题:^n" )
- nLen += format( szMenuBody[nLen], 255-nLen, "^n\w1. 操作1" )
- nLen += format( szMenuBody[nLen], 255-nLen, "^n\w2. 操作2" )
- nLen += format( szMenuBody[nLen], 255-nLen, "^n^n\w0. 退出" )
- keys = (1<<0|1<<1|1<<9)
- show_menu( id, keys, szMenuBody, -1 )
- return PLUGIN_CONTINUE
- }
- public MenuCommand( id, key )
- {
- client_print( id, print_console, "[AMX] Key=%d", key )
- client_print( id, print_chat, "[AMX] Key=%d", key )
- switch( key )
- {
- case 0: client_print( id, print_chat, "操作 #1" )
- case 1: client_print( id, print_chat, "操作 #2" )
- case 9: client_print( id, print_chat, "菜单操作退出" )
- }
- return PLUGIN_HANDLED
- }
- public get_keynumber() {
- code //获取用户按的数字,这部分代码要如何写?
- }
复制代码 |
|