AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Bartime while button is pressed and aiming a player question... (https://forums.alliedmods.net/showthread.php?t=299386)

!Morte 07-13-2017 01:05

Bartime while button is pressed and aiming a player question...
 
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 
pressedButtonoldPressedButton;
    
pressedButton pev(idpev_button);
    
oldPressedButton pev(idpev_oldbuttons);
    
showBarTime[id] = true;
    
    if((
pressedButton IN_USE))
    {
        static 
idTargetidLastTarget = -1idBody;
        
get_user_aiming(ididTargetidBody1000);
        
        if(
idTarget == idLastTarget)
        {
            
client_print(idprint_chat"You are aiming a player");
            
            
            if(
showBarTime[id])
            {
                
message_begin(MSG_ONEg_msgBarTime_id)
                
write_byte(3)
                
write_byte(0)
                
message_end()
                
                
showBarTime[id] = false;
                
                return 
PLUGIN_CONTINUE;
            }
        }
        
        if(
idLastTarget != idTarget && idLastTarget != -1)
        {
            
client_print(idprint_chat"You stop aiming a player");
            
pressedButton = !(pressedButton IN_USE);
            
showBarTime[id] = false;
            
            
message_begin(MSG_ONEg_msgBarTime_id)
            
write_byte(0)
            
write_byte(0)
            
message_end()
            
            return 
PLUGIN_CONTINUE;
        }
        
        
idLastTarget = ( idTarget == ) ? -idTarget;
    }
    
    
    if((
oldPressedButton IN_USE) && !(pressedButton IN_USE))
    {
        
client_print(idprint_chat"E released");
        
showBarTime[id] = false;
        
        
message_begin(MSG_ONEg_msgBarTime_id)
        
write_byte(0)
        
write_byte(0)
        
message_end()
    }
        
    return 
PLUGIN_CONTINUE;




All times are GMT -4. The time now is 22:47.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.