AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Timer Problem. (https://forums.alliedmods.net/showthread.php?t=225335)

tanayraj 09-03-2013 11:07

Timer Problem.
 
1 Attachment(s)
Hey ! i was just trying to make a simple timer :) .In which when we type /lotto its starts a countdown to 0 from 5 mins and if we type /results it displays the type left for it to end.
I am a getting a problem. When the timer reaches "4 Minutes and 0 Secs" after that it displays time like "-1 , -60" and weird stuff.I want it to display "3 Minutes and 59 secs" and then continue to till "0 minutes and 0 secs"

akcaliberg 09-03-2013 11:16

Re: Timer Problem.
 
you forgot to check if minutes and seconds are both zero. So task loop will continue permanently

tanayraj 09-03-2013 11:20

Re: Timer Problem.
 
Quote:

Originally Posted by akcaliberg (Post 2027636)
you forgot to check if minutes and seconds are both zero. So task loop will continue permanently

I dont know how to please fix it.
Thanks. (PS - i am new too pawn)

akcaliberg 09-03-2013 11:41

Re: Timer Problem.
 
PHP Code:

public Counter(id)
{
    
id -= TaskID_Counter

    Results_TimeLeft_Secs
[id]--

    if (!
Results_TimeLeft_Secs[id])
    {
    
        if(!
Results_Timeleft_Mins[id]) return
        else 
Results_TimeLeft_Mins[id]--

    }

    
set_task(1.0"Counter"id TaskID_Counter)



tanayraj 09-03-2013 15:34

Re: Timer Problem.
 
Not working.

Black Rose 09-03-2013 15:54

Re: Timer Problem.
 
Code:
public Counter(id) {     id -= TaskID_Counter         Results_TimeLeft_Secs[id]--         if ( ! Results_TimeLeft_Secs[id] && ! Results_TimeLeft_Mins[id] ) {         Lotto_Results(id);         return;     }         if ( Results_TimeLeft_Secs[id] == -1 ) {         Results_TimeLeft_Mins[id]--;         Results_TimeLeft_Secs[id] = 59;     }         set_task(1.0, "Counter", id + TaskID_Counter) }


All times are GMT -4. The time now is 19:04.

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