|
发表于 2005-9-2 22:22:34
|
显示全部楼层
来自 中国–重庆–重庆–南岸区
回复: 【原创】怎样使用循环语句来精简代码--表情插件多页菜单制作
呵呵,不过现在的菜单插件都是这种的。。。。。
对了,我改了下你的插件,不过出错了,你们谁有空帮我看看是哪点的问题!
- #include <amxmod>
- #define TE_PLAYERATTACHMENT 124
- new boss
- new byebye
- new cold
- new cool
- new cry
- new gogogo
- new haixiu
- new happy
- new kiss
- new koushui
- new mad
- new qiang
- new sad
- new se
- new shangxiang
- new shaxiao
- new smile
- new spiderman
- new sure
- new sweat
- new wenhao
- new wunai
- new wuyu
- new xieyan
- new xinzui
- new zhoumei
- public plugin_init()
- {
- register_plugin("face show","0.3","[Grief.QQ]")
- register_clcmd( "say /facemenu","FirstPageMenu",0)
- register_menucmd(register_menuid("\wFirstPage"),1023,"FirstMenuCmd")
- register_menucmd(register_menuid("\wSecondPage"),1023,"SecondMenuCmd")
- register_menucmd(register_menuid("\wThirdPage"),1023,"ThirdMenuCmd")
- register_menucmd(register_menuid("\wFourthPage"),1023,"FourthMenuCmd")
- return PLUGIN_CONTINUE
- }
- public plugin_precache()
- {
- boss = precache_model("sprites/boss.spr")
- byebye = precache_model("sprites/byebye.spr")
- cold = precache_model("sprites/cold.spr")
- cool = precache_model("sprites/cool.spr")
- cry = precache_model("sprites/cry.spr")
- gogogo = precache_model("sprites/gogogo.spr")
- haixiu = precache_model("sprites/haixiu.spr")
- happy = precache_model("sprites/happy.spr")
- kiss = precache_model("sprites/kiss.spr")
- koushui = precache_model("sprites/koushui.spr")
- mad = precache_model("sprites/mad.spr")
- qiang = precache_model("sprites/qiang.spr")
- sad = precache_model("sprites/sad.spr")
- se = precache_model("sprites/se.spr")
- shangxiang = precache_model("sprites/shangxiang.spr")
- shaxiao = precache_model("sprites/shaxiao.spr")
- smile = precache_model("sprites/smile.spr")
- spiderman = precache_model("sprites/spiderman.spr")
- sure = precache_model("sprites/sure.spr")
- sweat = precache_model("sprites/sweat.spr")
- wenhao = precache_model("sprites/wenhao.spr")
- wunai = precache_model("sprites/wunai.spr")
- wuyu = precache_model("sprites/wuyu.spr")
- xieyan = precache_model("sprites/xieyan.spr")
- xinzui = precache_model("sprites/xinzui.spr")
- zhoumei = precache_model("sprites/zhoumei.spr")
- }
- public cmdboss(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(boss)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdbyebye(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(byebye)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdcold(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(cold)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdcool(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(cool)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdcry(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(cry)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdgogogo(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(gogogo)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdhaixiu(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(haixiu)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdhappy(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(happy)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdkiss(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(kiss)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdkoushui(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(koushui)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdmad(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(mad)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdqiang(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(qiang)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdsad(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(sad)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdse(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(se)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdshangxiang(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(shangxiang)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdshaxiao(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(shaxiao)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdsmile(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(smile)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdspiderman(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(spiderman)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdsure(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(sure)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdsweat(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(sweat)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdwenhao(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(wenhao)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdwunai(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(wunai)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdwuyu(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(wuyu)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdxieyan(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(xieyan)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdxinzui(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(xinzui)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public cmdzhoumei(id)
- {
- 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
- }
- message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},id)
- write_byte(TE_PLAYERATTACHMENT)
- write_byte(id)
- write_coord(40)
- write_short(zhoumei)
- write_short(30)
- message_end()
- return PLUGIN_HANDLED
- }
- public FirstPageMenu( id )
- {
- new testMenu[512]
- new coun = 0
- new i
- new keys = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9)
- new menu_gut[8][] = {"","byebye","cold","cool","娴娉","GOGOGO","瀹崇","楂"}
- coun += format( testMenu[coun], 511-coun, "\wFirstPage^n^n" )
- for ( i = 0; i < 8; i++ )
- {
- coun += format( testMenu[coun], 511-coun, "\w%d. %s^n",i+1,menu_gut[i] )
- }
- coun += format( testMenu[coun], 511-coun, "^n\w9. NEXT")
- coun += format( testMenu[coun], 511-coun, "\w0. EXIT")
- show_menu(id,keys,testMenu,-1)
- return PLUGIN_CONTINUE
- }
- public SecondPageMenu( id )
- {
- new coun = 0
- new j
- new testMenu[512]
- new keys = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9)
- new menu_gut[8][] = {"KISS","f按","unhappy","qiang","蹭激","茬","涓","荤"}
- coun += format( testMenu[coun], 511-coun, "\wSecondPage^n^n" )
- for ( j = 0; j < 8; j++ )
- {
- coun += format( testMenu[coun], 511-coun, "\w%d. %s^n",j+1,menu_gut[j] )
- }
- coun += format( testMenu[coun], 511-coun, "^n\w9. NEXT")
- coun += format( testMenu[coun], 511-coun, "\w0. BACK")
- show_menu(id,keys,testMenu,-1)
- return PLUGIN_CONTINUE
- }
- public ThirdPageMenu( id )
- {
- new coun = 0
- new k
- new testMenu[512]
- new keys = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9)
- new menu_gut[8][] = {"寰绗","渚?","姘","姹姘","","濂","璇",""}
- coun += format( testMenu[coun], 511-coun, "\wThirdPage^n^n" )
- for ( k = 0; k < 8; k++ )
- {
- coun += format( testMenu[coun], 511-coun, "\w%d. %s^n",k+1,menu_gut[k] )
- }
- coun += format( testMenu[coun], 511-coun, "^n\w9. NEXT")
- coun += format( testMenu[coun], 511-coun, "\w0. BACK")
- show_menu(id,keys,testMenu,-1)
- return PLUGIN_CONTINUE
- }
- public FourthPageMenu( id )
- {
- new coun = 0
- new l
- new testMenu[512]
- new keys = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9)
- new menu_gut[2][] = {"蹇","辩"}
- coun += format( testMenu[coun], 511-coun, "\wFourthPage^n^n" )
- for ( l = 0; l < 8; l++ )
- {
- coun += format( testMenu[coun], 511-coun, "\w%d. %s^n",l+1,menu_gut[l] )
- }
- coun += format( testMenu[coun], 511-coun, "^n^n\w0. BACK")
- show_menu(id,keys,testMenu,-1)
- return PLUGIN_CONTINUE
- }
- public FirstMenuCmd(id,key)
- {
- switch( key )
- {
- case 0: cmdboss(id)
- case 1: cmdbyebye(id)
- case 2: cmdcold(id)
- case 3: cmdcool(id)
- case 4: cmdcry(id)
- case 5: cmdgogogo(id)
- case 6: cmdhaixiu(id)
- case 7: cmdhappy(id)
- case 8: SecondPageMenu( id )
- case 9: return PLUGIN_HANDLED
- }
- return PLUGIN_HANDLED
- }
- public SecondMenuCmd(id,key)
- {
- switch( key )
- {
- case 0: cmdkiss(id)
- case 1: cmdkoushui(id)
- case 2: cmdmad(id)
- case 3: cmdqiang(id)
- case 4: cmdsad(id)
- case 5: cmdse(id)
- case 6: cmdshangxiang(id)
- case 7: cmdshaxiao(id)
- case 8: ThirdPageMenu( id )
- case 9: FirstPageMenu( id )
- }
- return PLUGIN_HANDLED
- }
- public ThirdMenuCmd(id,key)
- {
- switch( key )
- {
- case 0: cmdsmile(id)
- case 1: cmdspiderman(id)
- case 2: cmdsure(id)
- case 3: cmdsweat(id)
- case 4: cmdwenhao(id)
- case 5: cmdwunai(id)
- case 6: cmdwuyu(id)
- case 7: cmdxieyan(id)
- case 8: FourthPageMenu( id )
- case 9: SecondPageMenu( id )
- }
- return PLUGIN_HANDLED
- }
- public FourthMenuCmd(id,key)
- {
- switch( key )
- {
- case 0: cmdxinzui(id)
- case 1: cmdzhoumei(id)
- case 9: ThirdPageMenu( id )
- }
- return PLUGIN_HANDLED
- }
复制代码
大概的形容一下出错情况,首先是换页的地方是这样显示的"9. NEXT10. BACK"没换行,不过按9和0又是分别的NEXT和BACK命令!
其次从第3页起表情无法打开,但第3页的菜单能打开,就是说在第三页选了一个表情后没反映,而且第3页点NEXT为直接退出,无法打开第四页,点BACK也是直接退出 |
|