#include <amxmodx>
#include <reapi>
//#define NOT_ALIVE
#define INFO_KILLER
//#define NO_ROUND
#if AMXX_VERSION_NUM < 183
#include <colorchat>
#define MAX_PLAYERS 32
#endif
#if AMXX_VERSION_NUM == 183
enum _:info
{
damage,
lasthit,
killerid,
killername[32],
Float:hpkiller,
Float:apkiller,
Float:distance
}
new g_iPlayerData[MAX_PLAYERS+1][info];
#else
enum _:info
{
damage,
lasthit,
killerid,
killername[32]
}
new g_iPlayerData[MAX_PLAYERS+1][info];
new Float:g_fHpKiller[MAX_PLAYERS+1];
new Float:g_fApKiller[MAX_PLAYERS+1];
new Float:g_fDistance[MAX_PLAYERS+1];
#endif
new g_iVOrigin[3], g_iKOrigin[3];
new const g_szHitPlaces[][] = { "-", "в голову", "в грудь", "в живот", "в левую руку", "в правую руку", "в левую ногу", "в правую ногу" };
public plugin_init()
{
register_plugin("[ReAPI] Say me and hp", "1.4", "neygomon");
register_event("Damage", "eventDamage", "b", "2!0");
#if defined NO_ROUND
RegisterHookChain(RG_CBasePlayer_Spawn, "fwdPlayerSpawn", true)
#else
register_event("HLTV", "eventRoundStart", "a", "1=0", "2=0");
#endif
RegisterHookChain(RG_CBasePlayer_Killed, "fwdPlayerKilled", true)
register_clcmd("say /me", "ClCmdSayMe");
register_clcmd("say_team /me", "ClCmdSayMe");
register_clcmd("say /hp", "ClCmdSayHp");
register_clcmd("say_team /hp", "ClCmdSayHp");
}
public client_putinserver(id)
{
arrayset(g_iPlayerData[id], 0, info);
#if AMXX_VERSION_NUM < 183
g_fHpKiller[id] = g_fApKiller[id] = g_fDistance[id] = 0.0;
#endif
}
#if defined NO_ROUND
public fwdPlayerSpawn(const id)
{
arrayset(g_iPlayerData[id], 0, info);
#if AMXX_VERSION_NUM < 183
g_fHpKiller[id] = g_fApKiller[id] = g_fDistance[id] = 0.0;
#endif
}
#else
public eventRoundStart()
{
for(new i = 1; i <= MAX_PLAYERS; i++)
{
arrayset(g_iPlayerData[i], 0, info);
#if AMXX_VERSION_NUM < 183
g_fHpKiller[i] = g_fApKiller[i] = g_fDistance[i] = 0.0;
#endif
}
}
#endif
public eventDamage(id)
{
static attacker, hit; attacker = get_user_attacker(id, 0, hit);
if(id != attacker && 1 <= attacker <= MAX_PLAYERS)
{
g_iPlayerData[attacker][damage] += read_data(2);
g_iPlayerData[attacker][lasthit] = hit;
}
}
public fwdPlayerKilled(pVictim, pKiller)
{
if(pVictim == pKiller || !is_user_connected(pKiller) || !is_user_connected(pVictim))
return;
get_user_origin(pVictim, g_iVOrigin);
get_user_origin(pKiller, g_iKOrigin);
#if AMXX_VERSION_NUM == 183
g_iPlayerData[pVictim][hpkiller] = get_entvar(pKiller, var_health);
g_iPlayerData[pVictim][apkiller] = get_entvar(pKiller, var_armorvalue);
g_iPlayerData[pVictim][distance] = get_distance(g_iKOrigin, g_iVOrigin) * 0.0254;
#else
g_fHpKiller[pVictim] = get_entvar(pKiller, var_health);
g_fApKiller[pVictim] = get_entvar(pKiller, var_armorvalue);
g_fDistance[pVictim] = get_distance(g_iKOrigin, g_iVOrigin) * 0.0254;
#endif
g_iPlayerData[pVictim][killerid] = pKiller;
get_user_name(pKiller, g_iPlayerData[pVictim][killername], charsmax(g_iPlayerData[][killername]));
#if defined INFO_KILLER
new pKilledByBomb = get_member(pVictim, m_bKilledByBomb);
if(g_iPlayerData[pVictim][killerid] != 0 && !pKilledByBomb)
ClCmdSayHp(pVictim);
if(g_iPlayerData[pVictim][damage] != 0)
ClCmdSayMe(pVictim);
#endif
}
public ClCmdSayMe(id)
{
#if defined NOT_ALIVE
if(is_user_alive(id))
{
client_print_color(id, 0, "^1[^4Stats^1] Доступно только ^4для мертвых ^1игроков.");
return PLUGIN_HANDLED;
}
#endif
switch(g_iPlayerData[id][damage])
{
case 0:client_print_color(id, 0, "^1[^4Stats^1] Вы ни в кого ^3не попали^1.");
default:client_print_color(id, 0, "^1[^4Stats^1] Вы нанесли ^3%d урона^1. Последнее попадание в ^4%s^1.", g_iPlayerData[id][damage], g_szHitPlaces[g_iPlayerData[id][lasthit]]);
}
return PLUGIN_HANDLED;
}
public ClCmdSayHp(id)
{
switch(g_iPlayerData[id][killerid])
{
case 0:client_print_color(id, 0, "^1[^4Stats^1] Вас никто ^3не убивал^1.");
#if AMXX_VERSION_NUM == 183
default:client_print_color(id, g_iPlayerData[id][killerid], "^1[^4Stats^1] Вас убил ^4%s ^1с расстояния ^3%.0f метров^1. У него осталось ^4%.0f HP ^1и ^4%.0f AP^1.", g_iPlayerData[id][killername], g_iPlayerData[id][distance], g_iPlayerData[id][hpkiller], g_iPlayerData[id][apkiller]);
#else
default:client_print_color(id, g_iPlayerData[id][killerid], "^1[^4Stats^1] Вас убил ^4%s ^1с расстояния ^3%.0f метров^1. У него осталось ^4%.0f HP ^1и ^4%.0f AP^1.", g_iPlayerData[id][killername], g_fDistance[id], g_fHpKiller[id], g_fApKiller[id]);
#endif
}
return PLUGIN_HANDLED;
}