|
自己修改的,有什么不对的地方请指出来,谢谢大家!
- #include <amxmodx>
- #include <fakemeta>
- #include <cstrike>
- #include <unlimited_money>
- #define DISTANCE 120
- new bool:g_bSolid[33]
- new Float:g_fOrigin[33][3]
- new bool:g_bHasSemiclip[33]
- new bool:g_MsgOn[33]
- new g_iMaxPlayers
- new HasBuy[33],g_money;
- new count[33]
- public plugin_init( )
- {
- register_plugin( "Antiblock", "1.1", "Maslyak&David Peng" )
-
- register_forward( FM_PlayerPreThink, "fwdPlayerPreThink" )
- register_forward( FM_PlayerPostThink, "fwdPlayerPostThink" )
- register_forward( FM_AddToFullPack, "fwdAddToFullPack_Post", 1 )
- register_event("HLTV", "EventNewRound", "a", "1=0", "2=0");
- register_clcmd("buy_ab", "buy_antiblock")
-
- g_iMaxPlayers = get_maxplayers( )
- }
- public EventNewRound()
- {
- new member=0
- for(new id=1; id<=g_iMaxPlayers; id++)
- {
- if(HasBuy[id]==1)
- {
- member++
- HasBuy[member]=0;
- }
- if (!is_user_alive(id)||!(get_user_flags(id)&ADMIN_LEVEL_F))
- {
- HasBuy[id]=0;
- }
- count[id]=0;
- }
- }
- public client_connect(id)
- {
- HasBuy[id] = 0;
- }
- public fwdPlayerPreThink( plr )
- {
- static id, last_think
- new P_name[33],D_name[33]
- new dpport[222]
- get_user_name(plr, D_name, 32);
- if( last_think > plr )
- {
- for( id = 1; id <= g_iMaxPlayers; id++ )
- {
- if( is_user_alive( id )&&HasBuy[plr]==1 )
- {
- g_bSolid[id] = pev( id, pev_solid ) == SOLID_SLIDEBOX ? true : false
- pev( id, pev_origin, g_fOrigin[id] )
- }
- else
- g_bSolid[id] = false
- }
- }
- last_think = plr
- if( g_bSolid[plr] )
- {
- for( id = 1; id <= g_iMaxPlayers; id++ )
- {
- new victim
- if( g_bSolid[id] && get_distance_f( g_fOrigin[plr], g_fOrigin[id] ) <= DISTANCE && id != plr&&get_user_team(id) == get_user_team(plr) )
- {
- if(!(pev(plr, pev_button) & IN_USE))
- return FMRES_IGNORED
- set_pev( id, pev_solid, SOLID_NOT )
- g_bHasSemiclip[id] = true
- g_MsgOn[plr] = true
- count[plr]++
- victim=id;
- get_user_name(victim, P_name, 32);
- }
- }
- if(g_MsgOn[plr]&&count[plr]==1)
- {
- format(dpport,222,"^x01【^x04提示^x01】^x03%s^01使用^x03【^x04穿人卡^x03】^x01穿过了他前面的^x03%s^x01!",D_name,P_name)
- client_color(0, plr, dpport)
- }
- }
- return FMRES_IGNORED
- }
- public fwdPlayerPostThink( plr )
- {
- static id
- for( id = 1; id <= g_iMaxPlayers; id++ )
- {
- if(g_bHasSemiclip[id])
- {
- set_pev( id, pev_solid, SOLID_SLIDEBOX )
- g_bHasSemiclip[id] = false
- }
- }
- if(g_MsgOn[plr])
- {
- g_MsgOn[plr] = false
- }
- if(!(pev(plr, pev_button) & IN_USE))
- {
- count[plr]=0;
- }
- }
- public fwdAddToFullPack_Post( es_handle, e, ent, host, hostflags, player, pset )
- {
- if( player&&HasBuy[host]==1)
- {
- if( g_bSolid[host] && g_bSolid[ent] && get_distance_f( g_fOrigin[host], g_fOrigin[ent] ) <= DISTANCE )
- {
- if(get_user_team(host) != get_user_team(ent))
- return FMRES_IGNORED
- if(!(pev(host, pev_button) & IN_USE))
- return FMRES_IGNORED
-
- set_es( es_handle, ES_Solid, SOLID_NOT ) // makes semiclip flawless
- set_es( es_handle, ES_RenderMode, kRenderTransAlpha )
- set_es( es_handle, ES_RenderAmt, 85 )
- }
- }
-
- return FMRES_IGNORED
- }
- public buy_antiblock(id)
- {
- new dpport[222],D_name[32];
- get_user_name(id, D_name, 31);
- g_money = cs_get_user_money2(id);
- if(HasBuy[id]==1)
- {
- format(dpport,222,"^x03您已经获得了该道具!")
- client_color(id,id,dpport)
- return PLUGIN_HANDLED;
- }
- if(!is_user_alive(id)) return PLUGIN_HANDLED;
- if(!is_user_connected(id)) return PLUGIN_HANDLED;
- if(g_money>=300)
- {
- cs_set_user_money2(id, g_money - 300)
- HasBuy[id]=1;
- format(dpport,222,"^x01【^x04提示^x01】^x03%s^01购买了^x03【^x04穿人卡^x03】^x01,现在他可以自由穿梭了!",D_name)
- client_color(0, id, dpport)
- }
- else if(g_money<300||HasBuy[id]==0)
- {
- format(dpport,222,"^x01你没有足够的资金购买^x03【^x04穿人卡^x03】^x01!")
- client_color(id, id, dpport)
- }
- return PLUGIN_CONTINUE;
- }
- public client_color(playerid,colorid,msg[])
- {
- message_begin(playerid?MSG_ONE:MSG_ALL, get_user_msgid("SayText"), {0,0,0}, playerid)
- write_byte(colorid)
- write_string(msg)
- message_end()
- }
- // is there a better way to detect changings of g_iCvar[0]?
复制代码 |
|