#include <amxmodx>
#include <reapi>
#define MAX_COORDINATES 3
#define IsTeam(%1) get_member(%1, m_iTeam)
enum any:CVARS
{
FRI_MP_ACCESS[MAX_NAME_LENGTH],
FRI_MP_RND_LIMIT,
FRI_MP_MK_MAX,
Float: FRI_MP_HP,
Float: FRI_MP_ADD_HP,
FRI_MP_ANIMATION[MAX_NAME_LENGTH],
Float: FRI_MP_SPEED_ANIM,
FRI_MP_HEAL_SPR,
FRI_MP_HEALER_SND,
FRI_MP_HEALED_SND
};
new g_Cvar[CVARS];
new const VIEW_MDL[] = "models/injection/v_syringe.mdl"; // Модель шприца в руках
new const PLAYER_MDL[] = "models/injection/p_syringe.mdl"; // Модель шприца со стороны
new const SND_HEAL[] = "injection/heal.wav"; // Звук для исцеляемого
new const SND_HEALING[] = "injection/medic.wav"; // Звук для целителя
new const HEALTH_SPR[] = "sprites/injection/heal_shape.spr"; // Спрайт после лечения
enum any:
{
STATUS_HIDE, // 0
STATUS_SHOW, // 1
STATUS_FLASH, // 2
}
const TASK_INDEX = 0xA6123;
new const SPRITE_MSG_NAME[] = "plus"; // Спрайт
new g_iMsgStatusIcon;
new g_iHealSprite;
new g_iHealter[MAX_PLAYERS+1];
enum _: INT_VALUES_NAMES
{
HID, // id использующего
PLID, // на ком используют
HWPN // оружие использующего
};
public plugin_init()
{
register_plugin("Injection Med-Kit", "1.0", "maFFyoZZyk");
register_dictionary("injection_med-kit.txt");
RegisterCvars();
AutoExecConfig(true, "injection_med-kit");
RegisterHookChain(RG_CBasePlayer_OnSpawnEquip, "CBasePlayer_OnSpawnEquip_Post", .post = true);
RegisterHookChain(RG_CBasePlayerWeapon_DefaultDeploy, "CBasePlayerWeapon_DefaultDeploy_Pre", .post = false);
g_iMsgStatusIcon = get_user_msgid("StatusIcon")
RegisterHookChain(RG_CBasePlayer_UseEmpty, "CBasePlayer_UseEmpty", .post = true);
RegisterHookChain(RG_PlantBomb, "PlantBomb", .post = true);
}
public plugin_precache()
{
precache_model(VIEW_MDL);
precache_model(PLAYER_MDL);
g_iHealSprite = precache_model(HEALTH_SPR);
precache_sound(SND_HEAL);
precache_sound(SND_HEALING);
}
public client_disconnected(id)
{
g_iHealter[id] = 0;
remove_task(id);
}
public CBasePlayer_OnSpawnEquip_Post(pPlayer)
{
if(!is_user_alive(pPlayer))
return HC_CONTINUE;
remove_task(pPlayer);
if(!(get_user_flags(pPlayer) & read_flags(g_Cvar[FRI_MP_ACCESS])))
return HC_CONTINUE;
g_iHealter[pPlayer] = 0; // обнуляем количество попыток лечения
set_msg_status_icon(pPlayer, STATUS_HIDE, SPRITE_MSG_NAME);
client_print_color(pPlayer, -2, "%L %L", LANG_PLAYER, "FRI_PREFIX", LANG_PLAYER, "FRI_EQUIPMSG");
set_task(0.1, "task_send_msg_status_icon", TASK_INDEX + pPlayer);
return HC_CONTINUE;
}
public CBasePlayerWeapon_DefaultDeploy_Pre(const pEntity, szViewModel[], szWeaponModel[], iAnim, szAnimExt[], skiplocal)
{
new pPlayer = get_member(pEntity, m_pPlayer);
if(!is_user_alive(pPlayer))
return;
if(task_exists(pPlayer))
{
rg_send_bartime(pPlayer, 0, true);
remove_task(pPlayer);
set_msg_status_icon(pPlayer, STATUS_HIDE, SPRITE_MSG_NAME);
set_msg_status_icon(pPlayer, STATUS_SHOW, SPRITE_MSG_NAME, 0, 128, 0);
}
}
public task_send_msg_status_icon(pPlayer)
{
pPlayer -= TASK_INDEX;
if(!is_user_alive(pPlayer))
return;
set_msg_status_icon(pPlayer, STATUS_SHOW, SPRITE_MSG_NAME, 0, 128, 0);
}
public CBasePlayer_UseEmpty(id)
{
if(!is_user_alive(id))
return HC_CONTINUE;
if(!(get_user_flags(id) & read_flags(g_Cvar[FRI_MP_ACCESS])))
return HC_CONTINUE;
if(~get_entvar(id, var_flags) & FL_ONGROUND)
return HC_CONTINUE;
if(g_iHealter[id] >= g_Cvar[FRI_MP_RND_LIMIT])
{
client_print_color(id, -2, "%L %L", LANG_PLAYER, "FRI_PREFIX", LANG_PLAYER, "FRI_EXHAUSTED");
return HC_CONTINUE;
}
if((Float:get_entvar(id, var_health) * 100.0 / Float:get_entvar(id, var_max_health)) >= g_Cvar[FRI_MP_HP])
{
client_print_color(id, -2, "%L %L", LANG_PLAYER, "FRI_PREFIX", LANG_PLAYER, "FRI_FULL");
return HC_CONTINUE;
}
new sArgValue[INT_VALUES_NAMES];
sArgValue[HID] = id;
sArgValue[HWPN] = get_member(id, m_pActiveItem);
if(is_nullent(sArgValue[HWPN]))
return HC_CONTINUE;
client_print_color(id, -2, "%L %L", LANG_PLAYER, "FRI_PREFIX", LANG_PLAYER, "FRI_USE");
set_entvar(id, var_viewmodel, VIEW_MDL);
set_entvar(id, var_weaponanim, 0);
set_entvar(id, var_weaponmodel, PLAYER_MDL);
// rg_set_player_animation(id, g_Cvar[FRI_MP_ANIMATION]);
set_msg_status_icon(id, STATUS_FLASH, SPRITE_MSG_NAME);
set_task(float(2), "Healing", id, sArgValue, sizeof(sArgValue));
rg_send_bartime(id, 2, true);
return HC_CONTINUE;
}
public Healing(sArgValue[], id)
{
new Float: fAddHealth = Float:get_entvar(sArgValue[HID], var_health) + g_Cvar[FRI_MP_ADD_HP];
if(fAddHealth > 100.0)
fAddHealth = 100.0;
set_entvar(sArgValue[HID], var_health, fAddHealth);
new Float:origin[3];
get_entvar(sArgValue[HID], var_origin, origin);
if(g_Cvar[FRI_MP_HEAL_SPR] == 1)
UTIL_SpriteTrail(origin, g_iHealSprite);
rg_switch_weapon(sArgValue[HID], sArgValue[HWPN]);
client_print_color(sArgValue[HID], -2, "%L %L", LANG_PLAYER, "FRI_PREFIX", LANG_PLAYER, "FRI_USED");
if(g_Cvar[FRI_MP_HEALER_SND])
emit_sound(0, CHAN_AUTO, SND_HEALING, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
if(g_Cvar[FRI_MP_HEALED_SND])
emit_sound(sArgValue[HID], CHAN_AUTO, SND_HEAL, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
set_msg_status_icon(sArgValue[HID], STATUS_HIDE, SPRITE_MSG_NAME);
g_iHealter[sArgValue[HID]]++;
if(g_iHealter[sArgValue[HID]] < g_Cvar[FRI_MP_RND_LIMIT])
set_task(0.1, "task_send_msg_status_icon", TASK_INDEX + sArgValue[HID]);
remove_task(id);
}
stock UTIL_SpriteTrail(Float:origin[3], const sprite, const cound = 20, const life = 20, const scale = 4, const noise = 20, const speed = 10) {
message_begin(MSG_BROADCAST, SVC_TEMPENTITY); // MSG_PVS
write_byte(TE_SPRITETRAIL);
write_coord_f(origin[0]);
write_coord_f(origin[1]);
write_coord_f(origin[2] + 20.0);
write_coord_f(origin[0]);
write_coord_f(origin[1]);
write_coord_f(origin[2] + 80.0);
write_short(sprite);
write_byte(cound);
write_byte(life);
write_byte(scale);
write_byte(noise);
write_byte(speed);
message_end();
}
stock set_msg_status_icon(pPlayer, iStatus, const sSprite[], iRed = 0, iGreen = 0, iBlue = 0)
{
message_begin(MSG_ONE, g_iMsgStatusIcon, .player = pPlayer);
write_byte(iStatus);
write_string(sSprite);
if(iStatus != STATUS_HIDE)
{
write_byte(iRed);
write_byte(iGreen);
write_byte(iBlue);
}
message_end();
}
stock rg_set_player_animation(const player_id, const anim_name[])
{
static anim_id, Float:fFrameRate, bool:bLoops, Float:fGroundSpeed;
if ((anim_id = lookup_sequence(player_id, anim_name, fFrameRate, bLoops, fGroundSpeed)) == -1)
anim_id = 0;
new Float:fGameTime = get_gametime();
set_entvar(player_id, var_frame, 0.0);
set_entvar(player_id, var_framerate, g_Cvar[FRI_MP_SPEED_ANIM]);
set_entvar(player_id, var_animtime, fGameTime );
set_entvar(player_id, var_sequence, anim_id);
set_member(player_id, m_fSequenceLoops, bLoops);
set_member(player_id, m_fSequenceFinished, 0);
set_member(player_id, m_flFrameRate, fFrameRate);
set_member(player_id, m_flGroundSpeed, fGroundSpeed);
set_member(player_id, m_flLastEventCheck, fGameTime);
set_member(player_id, m_Activity, 28);
set_member(player_id, m_IdealActivity, 28);
set_member(player_id, m_flLastEventCheck, fGameTime);
set_member(player_id, m_flLastFired, fGameTime );
}
RegisterCvars()
{
bind_pcvar_string(
create_cvar(
.name = "fri_mp_access",
.string = "z",
.flags = FCVAR_SERVER,
.description = fmt("%l", "FRI_CVAR_MP_ACCESS")
), g_Cvar[FRI_MP_ACCESS], charsmax(g_Cvar[FRI_MP_ACCESS])
);
bind_pcvar_num(
create_cvar(
.name = "fri_mp_rnd_limit",
.string = "1",
.flags = FCVAR_SERVER,
.description = fmt("%l", "FRI_CVAR_MP_RND_LIMIT"),
.has_min = true,
.min_val = 0.0
), g_Cvar[FRI_MP_RND_LIMIT]
);
bind_pcvar_num(
create_cvar(
.name = "fri_mp_mk_max",
.string = "1",
.flags = FCVAR_SERVER,
.description = fmt("%l", "FRI_CVAR_MP_MK_MAX"),
.has_min = true,
.min_val = 0.0
), g_Cvar[FRI_MP_MK_MAX]
);
bind_pcvar_float(
create_cvar(
.name = "fri_mp_hp",
.string = "80.0",
.flags = FCVAR_SERVER,
.description = fmt("%l", "FRI_CVAR_MP_HP"),
.has_min = true,
.min_val = 0.0
), g_Cvar[FRI_MP_HP]
);
bind_pcvar_float(
create_cvar(
.name = "fri_mp_add_hp",
.string = "50.0",
.flags = FCVAR_SERVER,
.description = fmt("%l", "FRI_CVAR_MP_ADD_HP"),
.has_min = true,
.min_val = 0.0
), g_Cvar[FRI_MP_ADD_HP]
);
bind_pcvar_string(
create_cvar(
.name = "fri_mp_animation",
.string = "ref_shoot_shieldknife",
.flags = FCVAR_SERVER,
.description = fmt("%l", "FRI_CVAR_MP_ANIMATION")
), g_Cvar[FRI_MP_ANIMATION], charsmax(g_Cvar[FRI_MP_ANIMATION])
);
bind_pcvar_float(
create_cvar(
.name = "fri_mp_speed_anim",
.string = "0.5",
.flags = FCVAR_SERVER,
.description = fmt("%l", "FRI_CVAR_MP_SPEED_ANIM"),
.has_min = true,
.min_val = 0.0
), g_Cvar[FRI_MP_SPEED_ANIM]
);
bind_pcvar_num(
create_cvar(
.name = "fri_mp_heal_spr",
.string = "1",
.flags = FCVAR_SERVER,
.description = fmt("%l", "FRI_CVAR_MP_HEAL_SPR"),
.has_min = true,
.min_val = 0.0
), g_Cvar[FRI_MP_HEAL_SPR]
);
bind_pcvar_num(
create_cvar(
.name = "fri_mp_healer_snd",
.string = "1",
.flags = FCVAR_SERVER,
.description = fmt("%l", "FRI_CVAR_MP_HEALER_SND"),
.has_min = true,
.min_val = 0.0
), g_Cvar[FRI_MP_HEALER_SND]
);
bind_pcvar_num(
create_cvar(
.name = "fri_mp_healed_snd",
.string = "1",
.flags = FCVAR_SERVER,
.description = fmt("%l", "FRI_CVAR_MP_HEALED_SND"),
.has_min = true,
.min_val = 0.0
), g_Cvar[FRI_MP_HEALED_SND]
);
}