|
发表于 2012-1-30 09:34:02
|
显示全部楼层
来自 中国–四川–成都
- #include <amxmodx>
- #include <amxmisc>
- #include <cstrike>
- #include <fun>
- #define MAXENTRYCOUNT 10
- #define MAXENTRYLENGTH 60
- #define MESSAGELENGTH MAXENTRYCOUNT*MAXENTRYLENGTH+20
- #define MAX_PLAYERS 32
- new ENTRY[MAXENTRYCOUNT][MAXENTRYLENGTH]
- new MESSAGE[MESSAGELENGTH]
- new DISPLAYCOLOR[3][3]
- new ENTRYCOUNT = 0
- new Float:TIMERWAIT = 1.0
- new DISPLAYTITLE[] = "举起你的右手,跟我一起发誓"
- new ADDENTRYCMD[] = "amx_addrule"
- new ADMINDISPLAYMESSAGECMD[] = "rules"
- new CHANGETEAM[] = "chooseteam"
- new pip[MAX_PLAYERS][22]
- new Float:rectime
- new CVARCOLOR[] = "sr_color"
- new CVARDISPLAY[] = "sr_display"
- public plugin_init() {
- register_plugin("Do you dare to pledge", "5.0", "DaBears")
- register_menucmd(register_menuid("请问你敢发誓吗?"),1023,"action_menu")
- register_menucmd(register_menuid("请选择队伍"),1023,"choose_team")
- register_menucmd(register_menuid("你要转移到哪一只队伍"),1023,"chooseteam")
- register_concmd(ADDENTRYCMD, "addentry", ADMIN_CVAR, "<entry> : Adds a entry")
- register_concmd(ADMINDISPLAYMESSAGECMD, "displaymessage", ADMIN_USER, ": Display message")
- register_concmd(CHANGETEAM, "teammenu", ADMIN_USER, ": Team menu")
- register_event("ShowMenu","join","b","4Team_Select")
- register_event("VGUIMenu","join","b","1=2","1=26","1=27")
- register_cvar(CVARDISPLAY, "60.0", 4)
- register_cvar(CVARCOLOR, "255,0,0", 4)
- register_cvar("minrec","15")
- set_msg_block(get_user_msgid("VGUIMenu"), BLOCK_SET)
- set_msg_block(get_user_msgid("ShowMenu"), BLOCK_SET)
- return PLUGIN_CONTINUE
- }
- public teammenu(id){
- new teammenu[1023]
- new len = format(teammenu,1023,"\w你要转移到哪一只队伍?: ^n^n\w")
- len += format(teammenu[len],1023-len,"^n\r1.\w 傻逼土匪.^n\r2.\w 垃圾警察.^n\r3.\w 偷窥者.^n\r0.\w 退出.")
- show_menu(id,(1<<0|1<<1|1<<2|1<<9),teammenu)
- return PLUGIN_HANDLED
- }
- public chooseteam(id, key)
- {
- switch (key)
- {
- case 0:
- {
- cs_set_user_team(id, CS_TEAM_T, CS_T_TERROR)
- client_cmd(id, "kill")
- }
- case 1:
- {
- cs_set_user_team(id, CS_TEAM_CT, CS_CT_SAS)
- client_cmd(id, "kill")
- }
- case 2:
- {
- cs_set_user_team(id, CS_TEAM_SPECTATOR, CS_DONTCHANGE)
- client_cmd(id, "kill")
- }
- case 9:
- {
- client_print( id, print_chat, "菜单退出" )
- }
- }
- return PLUGIN_HANDLED
- }
- public join(id){
- client_cmd(id,"setinfo ^"_vgui_menus^" ^"0^"")
- return PLUGIN_CONTINUE
- }
- public spawn_func(id)
- {
- new parm[1]
- parm[0]=id
- set_task(0.5,"spawnteam",_,parm,1)
- set_task(0.7,"spawnteam",_,parm,1)
- }
- public spawnteam(parm[1])
- {
- if(is_user_alive(parm[0]))
- return
- spawn(parm[0])
- }
- public client_putinserver(id)
- {
- set_task(TIMERWAIT, "displaymessage", id)
- }
- stock explode_string( p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter ) {
- new nIdx = 0, l = strlen(p_szInput)
- new nLen = (1 + copyc( p_szOutput[nIdx], p_nSize, p_szInput, p_szDelimiter ))
- while( (nLen < l) & (++nIdx < p_nMax) )
- nLen += (1 + copyc( p_szOutput[nIdx], p_nSize, p_szInput[nLen], p_szDelimiter ))
- return nIdx
- }
- public addentry(id,level,cid){
- if (!cmd_access(id,level,cid,2))
- return PLUGIN_HANDLED
- if (ENTRYCOUNT >= MAXENTRYCOUNT){
- return PLUGIN_HANDLED
- }
- read_argv(1,ENTRY[ENTRYCOUNT],MAXENTRYLENGTH)
- ENTRYCOUNT++
- return PLUGIN_HANDLED
- }
- public displaymessage(id) {
- new sDisplayColor[12]
- new Float:nDisplayTime = get_cvar_float(CVARDISPLAY)
- new text[1023]
- new len = format(text,1023,"\w请问你敢发誓吗?: ^n^n\w")
- len += format(text[len],1023-len,"^n\r8.\w 我不作弊,我敢发誓.^n\r9.\w 我是孬种,我不敢发誓.")
- show_menu(id,(1<<7|1<<8),text)
- get_cvar_string( CVARCOLOR, sDisplayColor, 12 )
- explode_string( DISPLAYCOLOR, 3, 3, sDisplayColor, ',' )
- format( MESSAGE, MESSAGELENGTH, DISPLAYTITLE )
- for ( new i=0; i<ENTRYCOUNT; ++i ) {
- format( MESSAGE, MESSAGELENGTH, "%s^n%d. %s", MESSAGE, i+1, ENTRY[i] )
- }
- set_hudmessage( str_to_num(DISPLAYCOLOR[0]), str_to_num(DISPLAYCOLOR[1]), str_to_num(DISPLAYCOLOR[2]), 0.025, 0.225, 2, 0.01, nDisplayTime, 0.01, 0.1, 4 )
- show_hudmessage( id, "%s", MESSAGE )
- client_print(id, print_center, "兄弟,请先发誓才能游戏哦,除非你是孬种,不敢发誓!")
- return PLUGIN_HANDLED
- }
- public action_menu(id,key)
- {
- switch( key )
- {
- case 7: {
- client_cmd(id, "bind m chooseteam")
- displaymenu(id)
- }
- case 8: {
- server_cmd("kick #%d ^"滚~~你个孬种!!^"", get_user_userid(id))
- }
- }
- return PLUGIN_HANDLED
- }
- public displaymenu(id)
- {
- new face[1023]
- new len = format(face,1023,"\w请选择队伍: ^n^n\w")
- len += format(face[len],1023-len,"^n\r1.\w 傻逼土匪.^n\r2.\w 垃圾警察.")
- show_menu(id,(1<<0|1<<1),face)
- return PLUGIN_HANDLED
- }
- public choose_team(id, key)
- {
- switch (key)
- {
- case 0:
- {
- client_cmd(id,"menuselect 1")
- client_cmd(id,"menuselect 5")
- spawn_func(id)
- }
- case 1:
- {
- client_cmd(id,"menuselect 2")
- client_cmd(id,"menuselect 5")
- spawn_func(id)
- }
- }
- return PLUGIN_HANDLED
- }
- public delayed_kick(user[]) {
- server_cmd("kick #%d^"由于网络繁忙,请15秒后在试!^"",user[0])
- }
- public cleanip(ind[]) {
- pip[ind[0]][0] = 0
- }
- public client_connect(id) {
- if (!is_user_bot(id)) {
- rectime = get_cvar_float("minrec")
- new userip[21+1]
- new uname[33+1]
- get_user_ip(id, userip, 21, 0)
- get_user_name(id, uname, 33)
- client_cmd(id, "bind m rules")
- for(new i = 1; i <= MAX_PLAYERS; i++) {
- if (equal(userip, pip[i], 21)) {
- new userid[1]
- userid[0] = get_user_userid(id)
- if (!(get_user_flags(id)ADMIN_IMMUNITY)) {
- set_task(1.0,"delayed_kick",0,userid,1)
- }
- return PLUGIN_CONTINUE
- }
- }
- }
- return PLUGIN_CONTINUE
- }
- public client_disconnect(id) {
- if (!is_user_bot(id)) {
- for(new i = 1; i <= MAX_PLAYERS; i++) {
- if(pip[i][0] == 0) {
- new userip[21+1]
- get_user_ip(id, userip, 21, 0)
- copy(pip[i], 21, userip)
- new userid[1]
- userid[0] = i
- set_task(rectime, "cleanip", 0, userid[0], 1)
- return PLUGIN_CONTINUE
- }
- }
- }
- return PLUGIN_CONTINUE
- }
复制代码 |
|