Raised This Month: $51 Target: $400
 12% 

Help with timer (set_task)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Arje
Senior Member
Join Date: Apr 2020
Location: Córdoba, Argentina
Old 01-25-2022 , 17:24   Help with timer (set_task)
Reply With Quote #1

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

Arje is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-25-2022 , 22:58   Re: Help with timer (set_task)
Reply With Quote #2

Instead of trying to sync up your set_task() interval with progressbar(, 3), why not call powerCharged from progressbar() when it's finished?
__________________
Bugsy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:53.


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