我自己加了一点东西
我改成Ts在C4装设之后,可以直接取得距离
而CT则是会得到取得距离的指令,在付出1000元的代价后,才能取得距离
-钱的部份在plugin_init之中的cost,最后面的数字就是扣除的金钱
复制程式
#include <amxmodx>
#include <fakemeta>
#include <csx>
#include <cstrike>
new bool:planted
new bool:buy
new Float:C4Origin[3]
new Maxplayers
new cost
public plugin_init(){
register_plugin("Show Distance","1.0","storym88349")
register_event("HLTV", "event_RoundStart", "a", "1=0", "2=0")
cost = register_cvar("cost_money","1000")
register_clcmd("say get_distance","pay",-1,"- pay for get distance")
Maxplayers = get_maxplayers()
set_task(0.01, "hud",0,"",0,"b")
}
public bomb_planted(planter){
planted = true
pev(planter, pev_origin, C4Origin)
return PLUGIN_CONTINUE;
}
public event_RoundStart(){
buy = false
planted = false
}
public bomb_explode(id){
planted = false
return PLUGIN_HANDLED;
}
public bomb_defused(id){
planted = false
return PLUGIN_HANDLED;
}
public pay(id){
new money = cs_get_user_money(id)
new CsTeams:userTeam = cs_get_user_team(id)
if ( ( money - get_pcvar_num(cost) ) >= 0 && userTeam == CS_TEAM_CT){
cs_set_user_money(id,money - get_pcvar_num(cost),1);
buy = true
return PLUGIN_HANDLED;
}
else {
set_hudmessage(225, 25, 25, 0.47, 0.73, 0, 1.0, 3.0, 0.2, 2.0, 15);
show_hudmessage(id, "你的金钱不足!");
}
return PLUGIN_HANDLED;
}
public hud(id){
new Float:Origin[3], Float:c4Dis
for (new id = 1; id <= Maxplayers; id++){
if (!is_user_connected(id) || !is_user_alive(id))
continue;
pev(id, pev_origin, Origin)
c4Dis = get_distance_f (C4Origin,Origin);
new CsTeams:userTeam = cs_get_user_team(id)
if(userTeam == CS_TEAM_T){
buy = true;
}
set_hudmessage(225, 25, 25, 0.47, 0.73, 0, 1.0, 1.0, 0.1, 0.2, 15);
if (planted && buy){
show_hudmessage(id, "距离C4装设点:%4.1f", c4Dis);
}else if (buy == false && planted && userTeam == CS_TEAM_CT){
show_hudmessage(id,"C4已被装设!输入get_distance取得C4距离");
}else{
return PLUGIN_HANDLED;
}
}
return PLUGIN_CONTINUE;
}
测试的部份,就请有兴趣的人自己抓下去吧