AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with timer (set_task) (https://forums.alliedmods.net/showthread.php?t=336070)

Arje 01-25-2022 17:24

Help with timer (set_task)
 
well my problem is that I want to use the timer, but instead of setting it correctly, I feel that the "set_task(3.0, "powerCharged", id)" makes it work badly and does not count the time correctly

PHP Code:

new HeroTimer[SH_MAXSLOTS+1]

public 
plugin_init()
{
       
// LOOP
    
set_task(1.0,"ssjgohan_loop",0,"",0,"b")

}

// RESPOND TO KEYDOWN
public ssjgohan_kd()
{
    
HeroTimer[id] = get_cvar_num("ssjgohan_cooldown")

    if ( 
gPlayerUltimateUsed[id] ) {
        
playSoundDenySelect(id)
        
ssjgohan_loop()
        return 
PLUGIN_HANDLED
    
}

    
// Set some variables
    
g_usingPower[id] = true
    g_powerKeyUsed
[id] = true
    g_chargeOver
[id] = false

    emit_sound
(idCHAN_STATIC"shmod/ssjgohan_kamehame.wav"1.0ATTN_NORM0PITCH_NORM)
    
    
    
// Show a progress bar for time til charge is full
    
progressBar(id3)

    
// Must wait for full bar time/sound til power can be used, this task will set it ok
    
set_task(3.0"powerCharged"id)
    
    return 
PLUGIN_HANDLED
}
//----------------------------------------------------------------------------------------------
public ssjgohan_loop()
{
    if (!
shModActive()) return
    
    for ( new 
id 1id <= SH_MAXSLOTSid++ ) {
        if ( 
g_hasSSJGohan[id] && is_user_alive(id)  )  {
            if (
HeroTimer[id] > ) {
                
HeroTimer[id]--
                if (
gPlayerUltimateUsed[id] && HeroTimer[id] < 4){
                    
set_hudmessage(01002000.050.7010.12.00.10.189)
                    
show_hudmessage(id"La Habilidad de [%s] estara lista en: %d segundos."g_heroNameHeroTimer[id])
                                        }
                            }
                            
                    }
            }
}

public 
powerCharged(id)
{
g_chargeOver[id] = true



Bugsy 01-25-2022 22:58

Re: Help with timer (set_task)
 
Instead of trying to sync up your set_task() interval with progressbar(, 3), why not call powerCharged from progressbar() when it's finished?


All times are GMT -4. The time now is 11:31.

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