flexcorejz
Пользователь
- Регистрация
- 8 Ноя 2017
- Сообщения
- 303
- Симпатии
- 24
/*
Credits:
* Radius - помощь с кодом. Подсказки по оптимизации.
*/
#include <amxmodx>
#include <engine>
#include <hamsandwich>
//#define NOT_ALIVE // Использовать /me может только МЕРТВЫЙ игрок. Чтобы разрешить всем пользоваться, закомментируйте
#define INFO_KILLER // Информация /me и /hp после смерти игрока
//#define NO_ROUND // Поддержка бесконечного раунда.
#define msgSayText 76
#define maxPlayers 32
#if AMXX_VERSION_NUM == 183
enum _:info
{
damage,
lasthit,
killerid,
killername[32],
Float:hpkiller,
Float:apkiller,
Float:distance
}
new g_iPlayerData[maxPlayers+1][info];
#else
enum _:info
{
damage,
lasthit,
killerid,
killername[32]
}
new g_iPlayerData[maxPlayers+1][info];
new Float:g_fHpKiller[maxPlayers+1];
new Float:g_fApKiller[maxPlayers+1];
new Float:g_fDistance[maxPlayers+1];
#endif
new const g_szHitPlaces[][] = { "-", "голову", "грудь", "живот", "левую руку", "правую руку", "левую ногу", "правую ногу" };
public plugin_init()
{
register_plugin("Say me and Say hp", "1.4", "neygomon");
register_event("Damage", "eventDamage", "b", "2!0");
#if defined NO_ROUND
RegisterHam(Ham_Spawn, "player", "fwdPlayerSpawn", true);
#else
register_event("HLTV", "eventRoundStart", "a", "1=0", "2=0");
#endif
RegisterHam(Ham_Killed, "player", "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 <= maxPlayers; i++)
{
arrayset(g_iPlayerData, 0, info);
#if AMXX_VERSION_NUM < 183
g_fHpKiller = g_fApKiller = g_fDistance = 0.0;
#endif
}
}
#endif
public eventDamage(id)
{
static attacker, hit; attacker = get_user_attacker(id, 0, hit);
if(id != attacker && 1 <= attacker <= maxPlayers)
{
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;
#if AMXX_VERSION_NUM == 183
g_iPlayerData[pVictim][hpkiller] = entity_get_float(pKiller, EV_FL_health);
g_iPlayerData[pVictim][apkiller] = entity_get_float(pKiller, EV_FL_armorvalue);
g_iPlayerData[pVictim][distance] = entity_range(pKiller, pVictim) / 32.00;
#else
g_fHpKiller[pVictim] = entity_get_float(pKiller, EV_FL_health);
g_fApKiller[pVictim] = entity_get_float(pKiller, EV_FL_armorvalue);
g_fDistance[pVictim] = entity_range(pKiller, pVictim) / 32.00;
#endif
g_iPlayerData[pVictim][killerid] = pKiller;
get_user_name(pKiller, g_iPlayerData[pVictim][killername], charsmax(g_iPlayerData[][killername]));
#if defined INFO_KILLER
ClCmdSayHp(pVictim);
ClCmdSayMe(pVictim);
#endif
}
public ClCmdSayMe(id)
{
#if defined NOT_ALIVE
if(is_user_alive(id))
{
ChatColor(id, id, "^1[^3MG^1] ^4Данная функция доступна ^3только ^4мертвым игрокам!");
return PLUGIN_HANDLED;
}
#endif
switch(g_iPlayerData[id][killerid])
{
case 0: ChatColor(id, id, "^1[^4MG^1] ^1Вы ни в кого ^4не ^1попали.");
default:ChatColor(id, id, "^1[^4MG^1] ^1Вы нанесли ^4%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: ChatColor(id, id, "^1[^4MG^1] ^1Вас ^4никто ^1не убивал.");
#if AMXX_VERSION_NUM == 183
default:ChatColor(id, g_iPlayerData[id][killerid], "^1[^4MG^1] ^1Вас убил: ^4%s^1 с расстояния ^4%.0f^1 метров. У него осталось: ^4%.0f^1HP ^1и ^4%.0f^1AP", g_iPlayerData[id][killername], g_iPlayerData[id][distance], g_iPlayerData[id][hpkiller], g_iPlayerData[id][apkiller]);
#else
default:ChatColor(id, g_iPlayerData[id][killerid], "^1[^4MG^1] ^1Вас убил: ^4%s^1 с расстояния ^4%.0f^1 метров. У него осталось: ^4%.0f^1HP ^1и ^4%.0f^1AP", g_iPlayerData[id][killername], g_fDistance[id], g_fHpKiller[id], g_fApKiller[id]);
#endif
}
return PLUGIN_HANDLED;
}
stock ChatColor(id, id2, const szMessage[], any:...)
{
if(!is_user_connected(id))
return;
static szMsg[190]; vformat(szMsg, charsmax(szMsg), szMessage, 4);
message_begin(MSG_ONE, msgSayText, .player = id);
write_byte(id2);
write_string(szMsg);
message_end();
}
Credits:
* Radius - помощь с кодом. Подсказки по оптимизации.
*/
#include <amxmodx>
#include <engine>
#include <hamsandwich>
//#define NOT_ALIVE // Использовать /me может только МЕРТВЫЙ игрок. Чтобы разрешить всем пользоваться, закомментируйте
#define INFO_KILLER // Информация /me и /hp после смерти игрока
//#define NO_ROUND // Поддержка бесконечного раунда.
#define msgSayText 76
#define maxPlayers 32
#if AMXX_VERSION_NUM == 183
enum _:info
{
damage,
lasthit,
killerid,
killername[32],
Float:hpkiller,
Float:apkiller,
Float:distance
}
new g_iPlayerData[maxPlayers+1][info];
#else
enum _:info
{
damage,
lasthit,
killerid,
killername[32]
}
new g_iPlayerData[maxPlayers+1][info];
new Float:g_fHpKiller[maxPlayers+1];
new Float:g_fApKiller[maxPlayers+1];
new Float:g_fDistance[maxPlayers+1];
#endif
new const g_szHitPlaces[][] = { "-", "голову", "грудь", "живот", "левую руку", "правую руку", "левую ногу", "правую ногу" };
public plugin_init()
{
register_plugin("Say me and Say hp", "1.4", "neygomon");
register_event("Damage", "eventDamage", "b", "2!0");
#if defined NO_ROUND
RegisterHam(Ham_Spawn, "player", "fwdPlayerSpawn", true);
#else
register_event("HLTV", "eventRoundStart", "a", "1=0", "2=0");
#endif
RegisterHam(Ham_Killed, "player", "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 <= maxPlayers; i++)
{
arrayset(g_iPlayerData, 0, info);
#if AMXX_VERSION_NUM < 183
g_fHpKiller = g_fApKiller = g_fDistance = 0.0;
#endif
}
}
#endif
public eventDamage(id)
{
static attacker, hit; attacker = get_user_attacker(id, 0, hit);
if(id != attacker && 1 <= attacker <= maxPlayers)
{
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;
#if AMXX_VERSION_NUM == 183
g_iPlayerData[pVictim][hpkiller] = entity_get_float(pKiller, EV_FL_health);
g_iPlayerData[pVictim][apkiller] = entity_get_float(pKiller, EV_FL_armorvalue);
g_iPlayerData[pVictim][distance] = entity_range(pKiller, pVictim) / 32.00;
#else
g_fHpKiller[pVictim] = entity_get_float(pKiller, EV_FL_health);
g_fApKiller[pVictim] = entity_get_float(pKiller, EV_FL_armorvalue);
g_fDistance[pVictim] = entity_range(pKiller, pVictim) / 32.00;
#endif
g_iPlayerData[pVictim][killerid] = pKiller;
get_user_name(pKiller, g_iPlayerData[pVictim][killername], charsmax(g_iPlayerData[][killername]));
#if defined INFO_KILLER
ClCmdSayHp(pVictim);
ClCmdSayMe(pVictim);
#endif
}
public ClCmdSayMe(id)
{
#if defined NOT_ALIVE
if(is_user_alive(id))
{
ChatColor(id, id, "^1[^3MG^1] ^4Данная функция доступна ^3только ^4мертвым игрокам!");
return PLUGIN_HANDLED;
}
#endif
switch(g_iPlayerData[id][killerid])
{
case 0: ChatColor(id, id, "^1[^4MG^1] ^1Вы ни в кого ^4не ^1попали.");
default:ChatColor(id, id, "^1[^4MG^1] ^1Вы нанесли ^4%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: ChatColor(id, id, "^1[^4MG^1] ^1Вас ^4никто ^1не убивал.");
#if AMXX_VERSION_NUM == 183
default:ChatColor(id, g_iPlayerData[id][killerid], "^1[^4MG^1] ^1Вас убил: ^4%s^1 с расстояния ^4%.0f^1 метров. У него осталось: ^4%.0f^1HP ^1и ^4%.0f^1AP", g_iPlayerData[id][killername], g_iPlayerData[id][distance], g_iPlayerData[id][hpkiller], g_iPlayerData[id][apkiller]);
#else
default:ChatColor(id, g_iPlayerData[id][killerid], "^1[^4MG^1] ^1Вас убил: ^4%s^1 с расстояния ^4%.0f^1 метров. У него осталось: ^4%.0f^1HP ^1и ^4%.0f^1AP", g_iPlayerData[id][killername], g_fDistance[id], g_fHpKiller[id], g_fApKiller[id]);
#endif
}
return PLUGIN_HANDLED;
}
stock ChatColor(id, id2, const szMessage[], any:...)
{
if(!is_user_connected(id))
return;
static szMsg[190]; vformat(szMsg, charsmax(szMsg), szMessage, 4);
message_begin(MSG_ONE, msgSayText, .player = id);
write_byte(id2);
write_string(szMsg);
message_end();
}
Как сделать, чтобы когда тебя убили, тебе показывало только : ^1[^4MG^1] ^1Вас убил: ^4%s^1 с расстояния ^4%.0f^1 метров. У него осталось: ^4%.0f^1HP ^1и ^4%.0f^1AP", без того сколько ты урона нанес.