SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 24/08/2011, 02:15 AM   #11
Tigerbeast11
Gangsta
 
Join Date: Aug 2009
Posts: 771
Reputation: 2
Default Re: Timer won't Countdown!!!

Nice try, but still no success!
Tigerbeast11 is offline  
Old 24/08/2011, 03:28 AM   #12
iPLEOMAX
High-roller
 
iPLEOMAX's Avatar
 
Join Date: Mar 2011
Location: AE
Posts: 1,276
Reputation: 739
Default Re: Timer won't Countdown!!!

Try this:
Code:
new GameSeconds = 1451;
new Text:Textdraw0;

Code:
Textdraw0 = TextDrawCreate(86.000000,427.000000,"Loading..");
    TextDrawAlignment(Textdraw0,2);
    TextDrawBackgroundColor(Textdraw0,0x000000ff);
    TextDrawFont(Textdraw0,3);
    TextDrawLetterSize(Textdraw0,0.499999,2.000000);
    TextDrawColor(Textdraw0,0xffffffff);
    TextDrawSetOutline(Textdraw0,1);
    TextDrawSetProportional(Textdraw0,1);
    TextDrawSetShadow(Textdraw0,1);

Code:
public OnPlayerConnect(playerid)
{
	TextDrawShowForPlayer(playerid, Textdraw0);
	return true;
}

Code:
SetTimer("GameTime",1000,1);

Code:
forward GameTime();
public GameTime()
{
    GameSeconds++;
    new TimeString[14];
    format(TimeString,sizeof(TimeString),"%i:%i",(GameSeconds/(60*60))%24,(GameSeconds/60)%60);
    //                                 Hours:Minutes
    TextDrawSetString(Textdraw0,TimeString);
    //In case you need a reset on completing 24 hours:
    if((GameSeconds/(60*60))%24 == 24) { GameSeconds = 0; }
    return true;
}
//You don't need GameMinutes here. No other stuff.
__________________
Goodbye SA-MP.
iPLEOMAX is offline  
Old 24/08/2011, 03:41 AM   #13
Bakr
High-roller
 
Join Date: Apr 2011
Posts: 987
Reputation: 198
Default Re: Timer won't Countdown!!!

None of the previous posts will fix your problem. You need to hide and re-display the textdraw each time you set a new string to it, or it won't update on the player's screen. You should hide it, set the string, then show it again.
Code:
TextDrawHideForAll( Textdraw0 );
TextDrawSetString( Textdraw0, TimeString );
TextDrawShowForAll( Textdraw0 );
Bakr is offline  
Old 24/08/2011, 03:46 AM   #14
iPLEOMAX
High-roller
 
iPLEOMAX's Avatar
 
Join Date: Mar 2011
Location: AE
Posts: 1,276
Reputation: 739
Default Re: Timer won't Countdown!!!

Quote:
Originally Posted by Bakr View Post
None of the previous posts will fix your problem. You need to hide and re-display the textdraw each time you set a new string to it, or it won't update on the player's screen. You should hide it, set the string, then show it again.
Code:
TextDrawHideForAll( Textdraw0 );
TextDrawSetString( Textdraw0, TimeString );
TextDrawShowForAll( Textdraw0 );
Mine is tested and it works without it. (And I usually add that after string update though... Weird, lol.)
__________________
Goodbye SA-MP.
iPLEOMAX is offline  
Old 24/08/2011, 09:53 AM   #15
Tigerbeast11
Gangsta
 
Join Date: Aug 2009
Posts: 771
Reputation: 2
Default Re: Timer won't Countdown!!!

Quote:
Originally Posted by Bakr View Post
None of the previous posts will fix your problem. You need to hide and re-display the textdraw each time you set a new string to it, or it won't update on the player's screen. You should hide it, set the string, then show it again.
Code:
TextDrawHideForAll( Textdraw0 );
TextDrawSetString( Textdraw0, TimeString );
TextDrawShowForAll( Textdraw0 );
No, the timer doesn't countdown, even after putting it in the timer like this:

Code:
public GameTime()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(GameSeconds > 0 || GameMinutes > 0)
        {
            GameSeconds--;
            if(GameSeconds <= -1)
            {
                GameMinutes--;
                GameSeconds=59;
            }
            new TimeString[14];
            format(TimeString,sizeof(TimeString),"%02d:%02d",GameMinutes,GameSeconds);
            TextDrawSetString(Textdraw0,TimeString);
			TextDrawHideForAll( Textdraw0 );
			TextDrawSetString( Textdraw0, TimeString );
			TextDrawShowForAll( Textdraw0 );
        }
        if(GameSeconds == 0 && GameMinutes == 0)
        {
            OnGameModeExit();
        }
    }
    return 1;
}
Tigerbeast11 is offline  
Old 24/08/2011, 09:55 AM   #16
iPLEOMAX
High-roller
 
iPLEOMAX's Avatar
 
Join Date: Mar 2011
Location: AE
Posts: 1,276
Reputation: 739
Default Re: Timer won't Countdown!!!

Have you tried my method above?^
__________________
Goodbye SA-MP.
iPLEOMAX is offline  
Old 24/08/2011, 09:56 AM   #17
Tigerbeast11
Gangsta
 
Join Date: Aug 2009
Posts: 771
Reputation: 2
Default Re: Timer won't Countdown!!!

Im trying it now.
Tigerbeast11 is offline  
Old 24/08/2011, 09:59 AM   #18
Tigerbeast11
Gangsta
 
Join Date: Aug 2009
Posts: 771
Reputation: 2
Default Re: Timer won't Countdown!!!

Quote:
Originally Posted by iPLEOMAX View Post
Have you tried my method above?^
With your method, all I get is "Loading" in the bottom corner.
Tigerbeast11 is offline  
Old 24/08/2011, 10:06 AM   #19
iPLEOMAX
High-roller
 
iPLEOMAX's Avatar
 
Join Date: Mar 2011
Location: AE
Posts: 1,276
Reputation: 739
Default Re: Timer won't Countdown!!!

You sure you have done everything correctly? (Look at mine in the screeny here, with seconds )

__________________
Goodbye SA-MP.
iPLEOMAX is offline  
Old 24/08/2011, 10:08 AM   #20
Tigerbeast11
Gangsta
 
Join Date: Aug 2009
Posts: 771
Reputation: 2
Default Re: Timer won't Countdown!!!

Well, I copied and pasted your script so it should have worked. I honestly have no idea why it's doing this...
Tigerbeast11 is offline  
 

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
countdown timer The Woody Help Archive 7 18/06/2011 09:33 PM
[Help] Countdown timer in Textdraws Coldthug Help Archive 0 08/05/2010 02:16 PM
[SOLVED finaly :D] Really need help with countdown timer [HLF]Southclaw Help Archive 10 05/02/2010 05:39 PM
[SOLVED]Countdown Timer Tigerbeast11 Help Archive 11 24/11/2009 06:49 PM
Timer/Countdown/Million KyleLyndonSmith Help Archive 2 13/03/2009 12:29 PM


All times are GMT. The time now is 02:03 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.