Код
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <color>
#include <dhudmessage>
#define PLUGIN "HP on Kill"
#define VERSION "1.4"
#define AUTHOR "Blizzard"
#define PREFIX "!g[ Prefix ]!n"
new p_Hp; // This Holds The Amount HP To Give Upon A Kill
new p_HsHp; // This Holds The Amount HP To Give Upon Headshot
new p_MaxHp; // This Holds The Max Amount Of HP Player Can Have
new p_kill_msg; // This Will Hold Cvar On/Off For Announcing Who You Killed
new p_kill_hud; // This Will Hold Cvar On/Off For HP HUD Message.
new x_pos; // This Holds The X Pos For HUD
new y_pos; // This Holds The Y Pos For HUD
new bool:client_hud[33]; // This Will Hold Client On/Off For HP HUD Message.
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
p_Hp = register_cvar("amx_kill_hp", "15");
p_HsHp = register_cvar("amx_hs_hp", "20");
p_MaxHp = register_cvar("amx_hp_max", "100");
p_kill_msg = register_cvar("amx_kill_msg", "1");
p_kill_hud = register_cvar("amx_kill_hud", "1");
x_pos = register_cvar("amx_x_pos_hud", "0.01");
y_pos = register_cvar("amx_y_pos_hud", "0.89");
register_concmd("amx_kill_msgs", "Kill_Msg_Status", ADMIN_IMMUNITY, " 0 - Off | 1 - On");
register_clcmd("say /hudmsg", "cmd_HudMsg_Status", 0);
register_clcmd("say_team /hudmsg", "cmd_HudMsg_Status", 0);
register_event("DeathMsg", "Event_DeathMsg", "a", "1>0")
}
public client_putinserver(id) client_hud[id] = true;
public Event_DeathMsg()
{
new iKiller = read_data(1);
new iVictim = read_data(2);
new szName[32];
get_user_name(iVictim, szName, charsmax(szName));
if(iKiller && iVictim != iKiller)
{
new maxhp = get_pcvar_num(p_MaxHp);
new hp = get_user_health(iKiller);
if(hp != maxhp)
{
if(client_hud[iKiller])
set_dhudmessage(0, 255, 0, get_pcvar_float(x_pos), get_pcvar_float(y_pos), 0, 6.0, 6.0);
new bonusHP;
if(read_data(3))
{
bonusHP = get_pcvar_num(p_HsHp);
if(get_pcvar_num(p_kill_msg))
client_printc(iKiller, "%s You got!g %i!n health for killing !g%s with a Headshot", PREFIX, bonusHP, szName);
}
else
{
bonusHP = get_pcvar_num(p_Hp);
if(get_pcvar_num(p_kill_msg))
client_printc(iKiller, "%s You got!g %i!n health for killing !g%s", PREFIX, bonusHP, szName);
}
set_user_health(iKiller, hp + bonusHP);
hp = get_user_health(iKiller);
if(hp > maxhp)
{
set_user_health(iKiller, maxhp);
}
if(get_pcvar_num(p_kill_hud))
{
if(client_hud[iKiller]) show_dhudmessage(iKiller, "+%i HP", bonusHP);
}
}
}
}
public Kill_Msg_Status(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED;
new szArg[32], desc[22];
read_argv(1, szArg, charsmax(szArg));
if(equali(szArg, "0"))
{
set_pcvar_num(p_kill_msg, 0);
copy(desc, 21, "OFF");
}
else if(equali(szArg, "1"))
{
set_pcvar_num(p_kill_msg, 1);
copy(desc, 21, "ON");
}
console_print(id, "Kill Announce Message %s", desc);
client_printc(id, "%s Kill Announce Message !g%s", PREFIX, desc);
return PLUGIN_HANDLED;
}
public cmd_HudMsg_Status(id)
{
switch(client_hud[id])
{
case true:
{
client_hud[id] = false;
client_printc(id, "%s Your HP HUD Message is !gOFF", PREFIX);
}
case false:
{
client_hud[id] = true;
client_printc(id, "%s Your HP HUD Message is !gON", PREFIX);
}
}
return PLUGIN_HANDLED;
}