图 1.
new bool:g_job[33];
new bool:g_fast[33];
new bool:g_slow[33];
new bool:g_normal[33];
new bool:g_hp[33];
new bool:addhp[33];
new bool:ok[33];
new g_msg;
new g_beamSpr;
new job_name[5][0];
replace_all(String:string[], len, String:what[], String:with[])
{
new pos = 0;
new var1 = contain(string, what);
pos = var1;
if (var1 == -1)
{
return 0;
}
new total = 0;
new with_len = strlen(with);
new diff = strlen(what) - with_len;
new total_len = strlen(string);
new temp_pos = 0;
while (replace(string[pos], len - pos, what, with))
{
pos = with_len + pos;
total_len -= diff;
if (pos >= total_len)
{
return total;
}
else
{
temp_pos = contain(string[pos], what);
if (temp_pos == -1)
{
return total;
}
else
{
pos = temp_pos + pos;
total++;
}
return total;
}
return total;
}
return total;
}
public __fatal_ham_error(Ham:id, HamError:err, String:reason[])
{
!!! Removed Phi
if (func != -1 && callfunc_begin_i(func, -1) == 1)
{
callfunc_push_int(id);
callfunc_push_int(err);
callfunc_push_str(reason, false);
if (callfunc_end() == 1)
{
fail = 0;
}
}
if (fail)
{
set_fail_state(reason);
}
return 0;
}
xs_vec_add(Float:in1[], Float:in2[], Float:out[])
{
out[0] = in1[0] + in2[0];
out[1] = in1[1] + in2[1];
out[2] = in1[2] + in2[2];
return 0;
}
xs_vec_mul_scalar(Float:vec[], Float:scalar, Float:out[])
{
out[0] = vec[0] * scalar;
out[1] = vec[1] * scalar;
out[2] = vec[2] * scalar;
return 0;
}
Menu_Setting(menu)
{
menu_setprop(menu, 3, 40);
menu_setprop(menu, 2, 80);
menu_setprop(menu, 4, 120);
return 0;
}
client_printc(id, String:string[])
{
new msg[191];
new players[32];
new count = 1;
format(msg, 190, string, 3);
replace_all(msg, 190, "\g", "\4");
replace_all(msg, 190, "\y", "\1");
replace_all(msg, 190, "\t", "\3");
if (id)
{
players[0] = id;
}
else
{
get_players(players, count, "ch", "");
}
new index = 0;
new i = 0;
while (i < count)
{
index = players[i];
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), 256, index);
write_byte(index);
write_string(msg);
message_end();
i++;
}
return 0;
}
public plugin_init()
{
RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn", 1);
register_clcmd("say /choose_job", "ChooseMenu", -1, "", -1);
register_forward(FM_PlayerPreThink, "Player_PreThink", 0);
return 0;
}
public plugin_precache()
{
g_msg = CreateHudSyncObj(0);
g_beamSpr = precache_model("sprites/zbeam4.spr");
return 0;
}
public fw_PlayerSpawn(id)
{
set_task(0.00, "Reload", id + 10000, "", 0, "", 0);
client_printc(id, "\g[提示] \t如果未能选择兵种,可打指令/choose_job来开启选单。");
client_printc(id, "\g[提示] \t当医疗兵瞄准队友加血时,请不要到处跑,以免为医疗兵带来烦恼。");
new var1 = Heap_4;
var1[0] = 3356;
if (get_user_team(id, var1, 0) == 1)
{
set_user_rendering(id, 19, 255, 0, 0, 0, 15);
}
new var2 = Heap_4;
var2[0] = 3356;
if (get_user_team(id, var2, 0) == 2)
{
set_user_rendering(id, 19, 0, 0, 255, 0, 15);
}
return 0;
}
public Reload(id)
{
id += -10000;
strip_user_weapons(id);
give_item(id, "weapon_knife");
g_job[id] = 0;
g_fast[id] = 0;
g_slow[id] = 0;
g_normal[id] = 1;
ChooseMenu(id);
return 0;
}
public Player_PreThink(id)
{
if (!is_user_connected(id))
{
return 1;
}
if (!is_user_alive(id))
{
return 1;
}
static button;
button = pev(id, pev_button);
new target = 0;
new len = 0;
get_user_aiming(id, target, len, 9999);
new name[32];
get_user_name(target, name, 31);
new player1[3];
new player2[3];
get_user_origin(id, player1, 0);
get_user_origin(id, player2, 3);
new distance = get_distance(player1, player2);
if (g_hp[id][0][0])
{
if (distance < 201)
{
if (is_user_connected(target) && is_user_alive(target))
{
new var4 = Heap_4;
var4[0] = 3356;
if (get_user_team(id, var4, 0) == 1)
{
new var5 = Heap_4;
var5[0] = 3356;
if (get_user_team(target, var5, 0) == 1)
{
set_hudmessage(0, 255, 255, -1.00, 0.55, 0, 1.00, 0.50, 0.10, 0.20, -1);
ShowSyncHudMsg(id, g_msg, 3416, name, get_user_health(target));
if (button & 32)
{
if (100 > get_user_health(target))
{
if (!addhp[id][0][0])
{
addhp[id] = 1;
set_task(0.20, "addhp_F", id + 10000, "", 0, "", 0);
static Float:origin2[3];
static Float:origin1[3];
fm_get_aim_vector(id, 40, origin1, origin2);
new var6 = origin1[2];
new var2;
if (pev(id, pev_flags) & 16384)
{
var2 = 3.00/*1077936128*/;
}
else
{
var2 = -7.00/*-1059061760*/;
}
var6 = var6[0] + var2;
show_tracer_effect(origin1, origin2);
}
}
}
}
}
new var7 = Heap_4;
var7[0] = 3356;
if (get_user_team(id, var7, 0) == 2)
{
new var8 = Heap_4;
var8[0] = 3356;
if (get_user_team(target, var8, 0) == 2)
{
set_hudmessage(0, 255, 255, -1.00, 0.55, 0, 1.00, 0.50, 0.10, 0.20, -1);
ShowSyncHudMsg(id, g_msg, 3576, name, get_user_health(target));
if (button & 32)
{
if (100 > get_user_health(target))
{
if (!addhp[id][0][0])
{
addhp[id] = 1;
set_task(0.20, "addhp_F", id + 10000, "", 0, "", 0);
static Float:origin2[3];
static Float:origin1[3];
fm_get_aim_vector(id, 40, origin1, origin2);
new var9 = origin1[2];
new var3;
if (pev(id, pev_flags) & 16384)
{
var3 = 3.00/*1077936128*/;
}
else
{
var3 = -7.00/*-1059061760*/;
}
var9 = var9[0] + var3;
show_tracer_effect(origin1, origin2);
ok[id] = 1;
}
}
}
}
}
}
}
}
if (g_hp[id][0][0])
{
set_user_maxspeed(id, 300.00);
}
if (g_fast[id][0][0])
{
set_user_maxspeed(id, 300.00);
}
if (g_normal[id][0][0])
{
set_user_maxspeed(id, 250.00);
}
if (g_slow[id][0][0])
{
set_user_maxspeed(id, 200.00);
}
return 1;
}
public addhp_F(id)
{
id += -10000;
new target = 0;
new len = 0;
get_user_aiming(id, target, len, 9999);
ok[id] = 0;
new var1 = Heap_4;
var1[0] = 3356;
if (get_user_team(id, var1, 0) == 1)
{
new var2 = Heap_4;
var2[0] = 3356;
if (get_user_team(target, var2, 0) == 1)
{
if (get_user_health(target) == 99)
{
set_user_health(target, get_user_health(target) + 1);
}
set_user_health(target, get_user_health(target) + 2);
}
}
new var3 = Heap_4;
var3[0] = 3356;
if (get_user_team(id, var3, 0) == 2)
{
if (get_user_health(target) == 99)
{
set_user_health(target, get_user_health(target) + 1);
}
set_user_health(target, get_user_health(target) + 2);
}
addhp[id] = 0;
return 0;
}
fm_get_aim_vector(index, forward_distance, Float:forward_origin[3], Float:view_end_origin[3])
{
new Float:start[3];
new Float:view_ofs[3];
pev(index, pev_origin, start);
pev(index, pev_view_ofs, view_ofs);
xs_vec_add(start, view_ofs, start);
new Float:vector[3];
new Float:temp[3];
pev(index, pev_v_angle, vector);
engfunc(EngFunc_MakeVectors, vector);
global_get(glb_v_forward, vector);
xs_vec_mul_scalar(vector, float(forward_distance), temp);
xs_vec_add(start, temp, forward_origin);
new Float:dest[3];
xs_vec_mul_scalar(vector, 9999.00, temp);
xs_vec_add(start, temp, dest);
engfunc(EngFunc_TraceLine, start, dest, 0, index, 0);
get_tr2(0, TR_vecEndPos, view_end_origin);
return 1;
}
show_tracer_effect(Float:start_point[3], Float:end_point[3])
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY, 256, 0);
write_byte(0);
engfunc(EngFunc_WriteCoord, start_point);
engfunc(EngFunc_WriteCoord, start_point[1]);
engfunc(EngFunc_WriteCoord, start_point[2]);
engfunc(EngFunc_WriteCoord, end_point);
engfunc(EngFunc_WriteCoord, end_point[1]);
engfunc(EngFunc_WriteCoord, end_point[2]);
write_short(g_beamSpr);
write_byte(0);
write_byte(1);
write_byte(10);
write_byte(10);
write_byte(0);
write_byte(0);
write_byte(245);
write_byte(255);
write_byte(255);
write_byte(0);
message_end();
return 0;
}
public ChooseMenu(id)
{
if (g_job[id][0][0])
{
client_printc(id, "\g[兵种系统] \t你已经选择了兵种。");
return 1;
}
new menu = menu_create(3924, "ChooseMenu_Handler", 0);
new i = 0;
while (i < 5)
{
menu_additem(menu, job_name[i][0][0], "", 0, -1);
i++;
}
Menu_Setting(menu);
menu_display(id, menu, 0);
return 1;
}
public ChooseMenu_Handler(id, menu, item)
{
if (item == -3)
{
menu_destroy(menu);
return 1;
}
switch (item)
{
case 0:
{
give_item(id, "weapon_mp5navy");
cs_set_user_bpammo(id, CSW_MP5NAVY, 120);
g_job[id] = 1;
g_fast[id] = 1;
g_normal[id] = 0;
}
case 1:
{
give_item(id, "weapon_ak47");
cs_set_user_bpammo(id, CSW_AK47, 90);
g_job[id] = 1;
}
case 2:
{
give_item(id, "weapon_m4a1");
cs_set_user_bpammo(id, CSW_M4A1, 90);
g_job[id] = 1;
}
case 3:
{
give_item(id, "weapon_awp");
cs_set_user_bpammo(id, CSW_AWP, 30);
g_job[id] = 1;
g_slow[id] = 1;
g_normal[id] = 0;
}
case 4:
{
give_item(id, "weapon_knife");
g_job[id] = 1;
g_hp[id] = 1;
g_normal[id] = 0;
client_printc(id, "\g[兵种系统] \t你已经选择了医疗兵,瞄准队友按 E 回复血量(上限100血)。");
}
default:
{
}
}
return 1;
}