|
楼主 |
发表于 2005-9-8 18:57:17
|
显示全部楼层
来自 中国–广东–广州–白云区
回复: 【分享】浅谈表情插件制作经验
不会啊,因为你并不知道具体有多少菜单,但是,假如,如果多于一页,
那么,除了12345678八个正常的选择外,还需要9(更多,或者返回),0(退出)
所以,定义最大显示数量,但是这八个选择确是由变量生成的。
- #include <amxmod>
- #include <amxmisc>
- #define MAX_DISPLAY 8
- #define MAX_SPRITES 24
- #define TE_PLAYERATTACHMENT 124
- new get_spr_name[MAX_SPRITES][32]
- new get_spr_precached[MAX_SPRITES]
- new get_index_spr
- new g_nMenuPosition[33]
- public plugin_init()
- {
- register_plugin("Face Show", "0.2", "[Grief.QQ]")
- register_menucmd( register_menuid("\yPleaseChoose"), 1023, "MenuCommand" )
- register_clcmd( "say /face","DoShowMenu", 0 )
- return PLUGIN_CONTINUE
- }
- public plugin_precache()
- {
- get_index_spr = 0
- new sprite_file[64]
- new sprite_config[64]
- build_path(sprite_config, 63, "$basedir/config/spr_list.ini")
- new len, pos = 0
- if(file_exists(sprite_config))
- {
- while(read_file(sprite_config,pos++,get_spr_name[get_index_spr],31,len))
- {
- if( sprite_config[0] == ';' || !len ) continue
- format(sprite_file,63,"sprites/%s.spr",get_spr_name[get_index_spr])
- if(file_exists(sprite_file))
- {
- get_spr_precached[get_index_spr] = precache_model(sprite_file)
- get_index_spr++
- }
- }
- }
- return PLUGIN_CONTINUE
- }
- public MenuCommand( id, key )
- {
- switch( key )
- {
- case 8: ShowMenu( id, ++g_nMenuPosition[id] )
- case 9: ShowMenu( id, --g_nMenuPosition[id] )
- default:{
-
- if(!is_user_alive(id))
- {
- set_hudmessage(200, 100, 0, -1.0, 0.3, 0, 1.0, 5.0, 0.1, 0.2, 3)
- show_hudmessage(id,"Sorry,You Are Dead!!!")
- return PLUGIN_HANDLED
- }
-
- new spr_name = g_nMenuPosition[id]*MAX_DISPLAY + key
-
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id )
- write_byte ( TE_PLAYERATTACHMENT )
- write_byte(id)
- write_coord(60)
- write_short( get_spr_precached[spr_name] )
- write_short(30)
- message_end()
-
- return PLUGIN_HANDLED
- }
- }
- return PLUGIN_HANDLED
- }
- public ShowMenu( id, pos )
- {
- if( pos < 0 ) return
- new i, j = 0
- new nKeys, nStart, nEnd, nLen
- new faceMenuBody[512]
- nStart = pos * MAX_DISPLAY
- if( nStart >= MAX_SPRITES )
- nStart = pos = g_nMenuPosition[id] = 0
- nLen = format( faceMenuBody, 511, "\yPleaseChoose^n^n",pos + 1)
- nEnd = nStart + MAX_DISPLAY
- nKeys = (1<<9)
- if( nEnd > MAX_SPRITES ) nEnd = MAX_SPRITES
- for( i = nStart; i < nEnd; i++ )
- {
- nKeys |= (1<<j++)
- nLen += format( faceMenuBody[nLen], (511-nLen), "\w%d. %s^n\w", j, get_spr_name[i] )
- }
- if( nEnd != MAX_SPRITES )
- {
- format( faceMenuBody[nLen], (511-nLen), "^n9. More...^n0. %s", pos ? "Back" : "Exit" )
- nKeys |= (1<<8)
- }
- else format( faceMenuBody[nLen], (511-nLen), "^n0. %s", pos ? "Back" : "Exit" )
-
- show_menu(id,nKeys,faceMenuBody,-1)
- }
- public DoShowMenu( id, lvl, cid )
- {
- if( cmd_access( id, lvl, cid, 1 ) )
- ShowMenu( id, g_nMenuPosition[id] = 0 )
- return PLUGIN_HANDLED
- }
复制代码 |
|