While IN_USE button is held down and the player is aiming another player the bartime appears, and when the bartime ends something happend (that "something" is not coded). The thing is how can i make the bartime appears one time? I tried with a boolean but i don't know, i think there have to be another method, idk, and i don't know if is better to use PreThink instead CmdStart.
Btw, here is the code (is not clean and i touch it many times so i don't know if it works now xD):
PHP Code:
public Fw_CmdStart(id)
{
if(!is_user_alive(id))
return PLUGIN_HANDLED;
static pressedButton, oldPressedButton;
pressedButton = pev(id, pev_button);
oldPressedButton = pev(id, pev_oldbuttons);
showBarTime[id] = true;
if((pressedButton & IN_USE))
{
static idTarget, idLastTarget = -1, idBody;
get_user_aiming(id, idTarget, idBody, 1000);
if(idTarget == idLastTarget)
{
client_print(id, print_chat, "You are aiming a player");
if(showBarTime[id])
{
message_begin(MSG_ONE, g_msgBarTime, _, id)
write_byte(3)
write_byte(0)
message_end()
showBarTime[id] = false;
return PLUGIN_CONTINUE;
}
}
if(idLastTarget != idTarget && idLastTarget != -1)
{
client_print(id, print_chat, "You stop aiming a player");
pressedButton = !(pressedButton & IN_USE);
showBarTime[id] = false;
message_begin(MSG_ONE, g_msgBarTime, _, id)
write_byte(0)
write_byte(0)
message_end()
return PLUGIN_CONTINUE;
}
idLastTarget = ( idTarget == 0 ) ? -1 : idTarget;
}
if((oldPressedButton & IN_USE) && !(pressedButton & IN_USE))
{
client_print(id, print_chat, "E released");
showBarTime[id] = false;
message_begin(MSG_ONE, g_msgBarTime, _, id)
write_byte(0)
write_byte(0)
message_end()
}
return PLUGIN_CONTINUE;
}
__________________