#include <amxmodx>
#include <engine>
#tryinclude <lrs_csstats>
#define PLUGIN "LRS: Status Info"
#define AUTHOR "serfreeman1337, AcE"
#define VERSION "0.2"
const mStatusText = 106
new CVAR_ENEMY[128], CVAR_FRIEND[128]
enum _:isTpl
{
TPL_DIS
#if defined _lrs_csstats_included
,TPL_EXP, TPL_EXPNEED, TPL_LEVEL, TPL_MAXLEVEL, TPL_RANK
#endif
}
new isTplFormat[isTpl]
new tplForm[][] =
{
"<dis>"
#if defined _lrs_csstats_included
,"<exp>", "<nxp>", "<lvl>", "<mvl>", "<rnk>"
#endif
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
bind_pcvar_string(create_cvar("lrs_status_enemy", "1 Враг: %p2, Дистанция: <dis>"), CVAR_ENEMY, charsmax(CVAR_ENEMY))
bind_pcvar_string(create_cvar("lrs_status_friend", "1 Друг: %p2, HP %i3%%, Дистанция: <dis>"), CVAR_FRIEND, charsmax(CVAR_FRIEND))
register_event_ex("StatusValue", "Show_Status", RegisterEvent_Single | RegisterEvent_OnlyAlive | RegisterEvent_OnlyHuman, "1=2", "2!0")
}
public plugin_cfg()
{
for (new i; i < isTpl; ++ i)
{
if (contain(CVAR_FRIEND, tplForm[i]))
isTplFormat[i] |= (1<<0)
if (contain(CVAR_ENEMY, tplForm[i]))
isTplFormat[i] |= (1<<1)
}
}
public Show_Status(id)
{
new targetId = read_data(2)
new isEnemy = get_user_team(id) != get_user_team(targetId)
new statusTxt[128]
copy(statusTxt, 127, isEnemy ? CVAR_ENEMY : CVAR_FRIEND)
if (!tplFormat(id, targetId, statusTxt, 127, isEnemy))
return
message_begin(MSG_ONE, mStatusText, .player = id)
write_byte(0)
write_string(statusTxt)
message_end()
}
public tplFormat(id, targetId, statusTxt[], statusLen, isEnemy)
{
new tmp[32]
#if defined _lrs_csstats_included
new aStats[LRS_MAX_DATA]
if (!lrs_get_player_stats_thread(targetId, aStats))
return 0
#endif
for (new i; i < isTpl; ++ i)
{
if (isTplFormat[i] & (1<<isEnemy))
{
switch(i)
{
case TPL_DIS: formatex(tmp, 31, "%d", get_entity_distance(id, targetId))
#if defined _lrs_csstats_included
case TPL_EXP: formatex(tmp, 31, "%d", aStats[LRS_EXP])
case TPL_EXPNEED: formatex(tmp, 31, "%d", aStats[LRS_NEXT_LVL])
case TPL_LEVEL: formatex(tmp, 31, "%d", aStats[LRS_LVL])
case TPL_MAXLEVEL: formatex(tmp, 31, "%d", lrs_get_max_lvl())
case TPL_RANK: formatex(tmp, 31, "%s", aStats[LRS_LVL_NAME])
#endif
}
replace_all(statusTxt, statusLen, tplForm[i], tmp)
}
}
replace_all(statusTxt, statusLen, "\n", "^n")
return 1
}