Quote:
Originally Posted by ConnorMcLeod
I'm using this in client_prethink and it works as expected (both StatusValue and StatusText are BLOCK_SET):
|
So you're saying that this works?
PHP Code:
new g_msgStatusText;
new g_msgStatusValue;
new g_MaxPlayers;
public plugin_init()
{
register_forward(FM_PlayerPreThink, "fwdPlayerPreThink", 0);
g_msgStatusText = get_user_msgid("StatusText");
g_msgStatusValue = get_user_msgid("StatusValue");
set_msg_block(g_msgStatusText, BLOCK_SET);
set_msg_block(g_msgStatusValue, BLOCK_SET);
g_MaxPlayers = global_get(glb_maxClients);
}
public fwdPlayerPreThink(plr)
{
if( is_user_alive(plr) )
{
static old_target[33];
static reset[33];
new target, body;
get_user_aiming(plr, target, body, 9999);
if( 0 < target <= g_MaxPlayers && is_user_alive(target) )
{
new old = old_target[plr];
if( !old )
{
message_begin(MSG_ONE_UNRELIABLE, g_msgStatusValue, _, plr);
write_byte(1);
write_short((((!!(cs_get_user_team(plr) == cs_get_user_team(target))) + 1) % 2) + 1);
message_end();
}
if( old != target )
{
old_target[plr] = target;
message_begin(MSG_ONE_UNRELIABLE, g_msgStatusValue, _, plr);
write_byte(2);
write_short(target);
message_end();
}
if( !old )
{
message_begin(MSG_ONE_UNRELIABLE, g_msgStatusText, _, plr);
write_byte(0);
write_string("1 %p2");
message_end();
}
}
else
{
if( old_target[plr] )
{
reset[plr] = 100;
old_target[plr] = 0;
}
else if( reset[plr] > 0 && --reset[plr] == 0 )
{
message_begin(MSG_ONE_UNRELIABLE, g_msgStatusValue, _, plr);
write_byte(1);
write_short(0);
message_end();
}
}
}
}
__________________