可以讓死亡的隊友對著屍體按e救活[彷彿L4D的救活隊友]
預設花500錢救活隊友一條命
救人時有像拆炸彈時候中間一條時間軸在跑
用在殭屍模式也頗不錯的效果
ps:要先bind 您要設定的按鍵 + "reviva"
#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fun>
#define revive_delay 10
#define MSG_FAILED "Failed to Revive"
#define MSG_SUCCEED "Succeed to Revive"
#define MSG_START "Reviving"
#define REVIVE_TASK 1234
#define LOOP_BOOP 5678
#define ICON_HIDE 0
#define ICON_SHOW 1
#define ICON_FLASH 2
#define VER "1.0.1"
new g_msgBarTime, g_msgStatusIcon, pl_origins[33][3], reviverorigin[3], Float:oldspeed[33], bool:g_buyzone[33], bool:has_revkit[33] = false, dead_id
public plugin_init()
{
register_plugin("Reviver's Kit", VER, "Cheap_Suit")
register_cvar("amx_revivalkitcost", "500")
register_cvar("amx_revivehealth", "100")
register_clcmd("say /buyrevkit", "BuyRevivalKit")
register_clcmd("buyrevkit", "BuyRevivalKit")
register_clcmd("+revive", "revive_plus")
register_clcmd("-revive", "revive_minus")
register_event("DeathMsg","player_die","a")
register_event("StatusIcon", "Buy_Icon", "be", "2=buyzone")
register_event("ResetHUD", "newRound", "be")
g_msgBarTime = get_user_msgid("BarTime")
g_msgStatusIcon = get_user_msgid("StatusIcon")
}
//-- Plugin Precache, Plugin Modules
public plugin_precache()
{
precache_sound("fvox/boop.wav")
precache_sound("fvox/fuzz.wav")
precache_sound("fvox/administering_medical.wav")
precache_sound("fvox/wound_sterilized.wav")
precache_sound("vox/deeoo.wav")
precache_model("models/w_medkit.mdl")
}
public plugin_modules()
{
require_module("Engine")
require_module("cstrike")
require_module("fun")
}
//-- newRound, BuyRevivalKit, DropKit, pfn_touch, player_die
public newRound(id)
{
if(has_revkit[id] == false)
{
client_print(id, print_chat, "[AMXX] Type /buyrevkit or buyrevkit in your console to buy Reviver's Kit")
}
if(has_revkit[id] == true)
{
ReviveIcon(id, ICON_SHOW)
}
new revivalkit = find_ent_by_class(-1, "revivalkit")
while (revivalkit)
{
remove_entity(revivalkit)
revivalkit = find_ent_by_class(revivalkit, "revivalkit")
}
return PLUGIN_CONTINUE
}
public BuyRevivalKit(id)
{
new money = cs_get_user_money(id)
if(money >= get_cvar_num("amx_revivalkitcost") && g_buyzone[id] && has_revkit[id] == false)
{
client_print(id, print_center, "You bought a Revival Kit!")
client_print(id, print_chat, "[AMXX] bind a button to +revive")
client_cmd(id, "spk vox/deeoo.wav")
cs_set_user_money(id, money - get_cvar_num("amx_revivalkitcost"))
ReviveIcon(id, ICON_SHOW)
has_revkit[id] = true
}
return PLUGIN_HANDLED
}
public DropKit(id)
{
new Float:Aim[3], Float:origin[3]
VelocityByAim(id, 64, Aim)
entity_get_vector(id, EV_VEC_origin, origin)
origin[0] += Aim[0]
origin[1] += Aim[1]
new revivalkit = create_entity("info_target")
if(revivalkit > 0)
{
entity_set_string(revivalkit, EV_SZ_classname, "revivalkit")
entity_set_model(revivalkit, "models/w_medkit.mdl")
entity_set_size(revivalkit, Float:{-2.5, -2.5, -1.5}, Float:{2.5, 2.5, 1.5})
entity_set_int(revivalkit, EV_INT_solid, 1)
entity_set_int(revivalkit, EV_INT_movetype, 6)
entity_set_vector(revivalkit, EV_VEC_origin, origin)
}
ReviveIcon(id, 0)
has_revkit[id] = false
}
public pfn_touch(ptr, ptd)
{
if(is_valid_ent(ptd) && is_valid_ent(ptr) && is_user_connected(ptd) && is_user_alive(ptd))
{
new classname[32]
entity_get_string(ptr, EV_SZ_classname, classname, 31)
if(equal(classname, "revivalkit"))
{
if(has_revkit[ptd] == false)
{
client_cmd(ptd, "spk vox/deeoo.wav")
ReviveIcon(ptd, ICON_SHOW)
has_revkit[ptd] = true
remove_entity(ptr)
}
}
}
}
public player_die()
{
new victim = read_data(2)
get_user_origin(victim, pl_origins[victim], 0)
if(has_revkit[victim])
{
DropKit(victim)
}
return PLUGIN_CONTINUE
}
//-- revive_plus, revive_minus
public revive_plus(id)
{
if(!is_user_alive(id)) return PLUGIN_CONTINUE
new cur_origin[3], players[32], pl_num = 0, dist, last_dist = 99999
get_user_origin(id, cur_origin, 0)
get_players(players, pl_num, "b")
if(pl_num > 0)
{
for(new i = 0; i < pl_num; i++)
{
if(players!= id)
{
dist = get_distance(cur_origin, pl_origins[players])
if(dist < last_dist)
{
last_dist = dist
dead_id = players
}
}
}
if(last_dist < 80)
{
if(has_revkit[id])
{
if(!task_exists(REVIVE_TASK + id))
{
new name[33]
get_user_name(dead_id, name, 32)
client_print(id, print_center, "%s %s...", MSG_START, name)
oldspeed[id] = get_user_maxspeed(id)
set_user_maxspeed(id, 1.0)
emit_sound(id, CHAN_ITEM, "fvox/administering_medical.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
ProgressBar(id, revive_delay)
ReviveIcon(id, ICON_FLASH)
new param[2]
param[0] = id
set_task(float(revive_delay), "Revive_Player", REVIVE_TASK + id, param, 1)
set_task(3.0, "boop", LOOP_BOOP + id, param, 1)
}
}
}
else if(last_dist > 80)
{
if(has_revkit[id])
{
emit_sound(id, CHAN_ITEM, "common/wpn_denyselect.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
}
}
return PLUGIN_HANDLED
}
public revive_minus(id)
{
if(task_exists(REVIVE_TASK + id))
{
new name[33]
get_user_name(dead_id, name, 32)
client_print(id, print_center, "%s %s", MSG_FAILED, name)
ProgressBar(id, 0)
ReviveIcon(id, ICON_SHOW)
set_user_maxspeed(id, oldspeed[id])
remove_task(REVIVE_TASK + id)
}
if(task_exists(LOOP_BOOP + id))
{
emit_sound(id, CHAN_STATIC, "fvox/fuzz.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
remove_task(LOOP_BOOP + id)
}
return PLUGIN_HANDLED
}
//-- Revive_Player, respawn, boop
public Revive_Player(param[])
{
new id = param[0]
if(!is_user_alive(dead_id) && (cs_get_user_team(dead_id) == CS_TEAM_T|| cs_get_user_team(dead_id) == CS_TEAM_CT))
{
spawn(dead_id)
new origin[3] = {999, 999, 999}
set_user_origin(dead_id, origin)
set_task(3.0, "respawn", dead_id, param, 1)
}
new name[33]
get_user_name(dead_id, name, 32)
client_print(id, print_chat, "%s %s... please stand back", MSG_SUCCEED, name)
//emit_sound(id, CHAN_STATIC, "common/null.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
emit_sound(id, CHAN_STATIC, "fvox/wound_sterilized.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
get_user_origin(id, reviverorigin, 0)
set_user_maxspeed(id, oldspeed[id])
ReviveIcon(id, ICON_HIDE)
has_revkit[id] = false
remove_task(REVIVE_TASK + id)
remove_task(LOOP_BOOP + id)
}
public respawn(param[])
{
if(cs_get_user_team(dead_id) == CS_TEAM_SPECTATOR) return PLUGIN_CONTINUE
if(cs_get_user_team(dead_id) == CS_TEAM_T || cs_get_user_team(dead_id) == CS_TEAM_CT)
{
new id = param[0]
new name[33]
get_user_name(id, name, 32)
client_print(dead_id, print_chat, "Revived by %s", name)
spawn(dead_id)
reviverorigin[2] += 40
set_user_origin(dead_id, reviverorigin)
give_item(dead_id, "weapon_knife")
set_user_health(dead_id, get_cvar_num("amx_revivehealth"))
}
return PLUGIN_CONTINUE
}
public boop(param[])
{
new id = param[0]
emit_sound(id, CHAN_STATIC, "fvox/boop.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
set_task(1.5, "boop", LOOP_BOOP + id, param, 1)
}
//-- ProgressBar ReviveIcon, Buy_Icon
ProgressBar(id, seconds)
{
message_begin(MSG_ONE, g_msgBarTime, {0, 0, 0}, id)
write_byte(seconds)
write_byte(0)
message_end()
}
ReviveIcon(id, ICON)
{
message_begin(MSG_ONE, g_msgStatusIcon, {0, 0, 0}, id )
write_byte(ICON)
write_string("item_healthkit")
write_byte(0)
write_byte(160)
write_byte(0)
message_end()
}
public Buy_Icon(id)
{
if(read_data(1))
{
g_buyzone[id] = true
}
else
{
g_buyzone[id] = false
}
}
//-- End