Raised This Month: $ Target: $400
 0% 

Help with timer (set_task)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 11:31.


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