Скриптер
Проверенный
Пользователь
- Сообщения
- 3,569
- Реакции
- 1,560
- Помог
- 133 раз(а)
#include <amxmodx>
#include <cstrike>
#include <hamsandwich>
#define FREQ_TASK 0.5
#define TASK_INFORMER 3956
new g_msgStatusText, g_msgStatusValue
public plugin_init ()
{
register_plugin ("Player Status", "1.0", "Player Status")
register_event ("StatusValue", "ev_ShowStatus", "be", "1=2", "2!0")
register_event ("StatusValue", "ev_HideStatus", "be", "1=1", "2=0")
RegisterHam (Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
RegisterHam (Ham_Killed, "player", "fw_PlayerKilled")
g_msgStatusValue = get_user_msgid ("StatusValue")
g_msgStatusText = get_user_msgid ("StatusText")
}
public client_disconnect (id)
{
remove_task (id+TASK_INFORMER)
}
public fw_PlayerSpawn_Post (id)
{
if (!is_user_alive (id) || is_user_bot (id))
return
remove_task (id+TASK_INFORMER)
set_task (FREQ_TASK, "ShowPlayerInfo", id+TASK_INFORMER, .flags = "b")
}
public fw_PlayerKilled (victim)
{
if (is_user_bot (victim))
return
remove_task (victim+TASK_INFORMER)
}
public ShowPlayerInfo (id)
{
id -= TASK_INFORMER
static sMessage[191]
formatex (sMessage, charsmax (sMessage), "[Жизни: %i] [Броня: %i]", get_user_health (id), get_user_armor (id))
message_begin (MSG_ONE_UNRELIABLE, g_msgStatusText, .player = id)
write_byte (0)
write_string (sMessage)
message_end ()
}
public ev_HideStatus (id)
{
if (!is_user_bot (id) && is_user_connected (id))
{
message_begin (MSG_ONE_UNRELIABLE, g_msgStatusText, .player = id)
write_byte (0)
write_string ("")
message_end ()
remove_task (id+TASK_INFORMER)
ShowPlayerInfo (id+TASK_INFORMER)
set_task (FREQ_TASK, "ShowPlayerInfo", id+TASK_INFORMER, .flags = "b")
}
}
public ev_ShowStatus (id)
{
if (!is_user_bot (id) && is_user_connected (id))
{
remove_task (id+TASK_INFORMER)
new iTarget = read_data (2)
new sMessage[191]
if (cs_get_user_team (id) == cs_get_user_team (iTarget))
formatex (sMessage, charsmax (sMessage), "Друг: %%p2 - Здоровье: %i%% - Деньги: %i$", get_user_health (iTarget), cs_get_user_money (iTarget))
else
formatex (sMessage, charsmax (sMessage), "Враг: %%p2")
message_begin (MSG_ONE_UNRELIABLE, g_msgStatusText, .player = id )
write_byte (0)
write_string (sMessage)
message_end ()
message_begin (MSG_ONE_UNRELIABLE, g_msgStatusValue, .player = id)
write_byte (2)
write_short (iTarget)
message_end ()
}
}