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, 12:45 AM   #1
Tigerbeast11
Gangsta
 
Join Date: Aug 2009
Posts: 771
Reputation: 2
Default [SOLVED]Timer won't Countdown!!!

I have a textdraw with a timer:
Code:
new GameMinutes = 14;
new GameSeconds = 59;
new Text:Textdraw0;

Textdraw properties:
Code:
Textdraw0 = TextDrawCreate(86.000000,427.000000,"15:00");
	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);

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

Timer function:
Code:
public GameTime()
{
	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);
	}
	if(GameSeconds == 0 && GameMinutes == 0)
	{
		OnGameModeExit();
	}
	return 1;
}

When I go ingame, all I see is 15:00 and they timer doesn't count down! Please help me!

Last edited by Tigerbeast11; 24/08/2011 at 11:29 AM. Reason: [SOLVED]
Tigerbeast11 is offline  
Old 24/08/2011, 12:50 AM   #2
a_big
Big Clucker
 
Join Date: Jun 2011
Posts: 124
Reputation: 3
Default Re: Timer won't Countdown!!!

I know this is off-topic but couldnt you use the game clock?
a_big is offline  
Old 24/08/2011, 12:56 AM   #3
Jefff
High-roller
 
Join Date: Dec 2007
Posts: 2,585
Reputation: 294
Default Re: Timer won't Countdown!!!

Code:
new GameSeconds = 900; // 60s - min, 300s - 5min
public GameTime()
{
	new m = ((GameSeconds/60)%60);
	new s = (GameSeconds%60);
	new TimeString[14];
	format(TimeString,sizeof(TimeString),"%02d:%02d",m,s);
	TextDrawSetString(Textdraw0,TimeString);
	if(GameSeconds == 0) OnGameModeExit();
	GameSeconds--;
	return 1;
}
and TextDrawShowForAll or ForPlayer
Jefff is online now  
Old 24/08/2011, 12:56 AM   #4
Tigerbeast11
Gangsta
 
Join Date: Aug 2009
Posts: 771
Reputation: 2
Default Re: Timer won't Countdown!!!

@a_big: No, it's a countdown timer until the end of the gamemode.
Tigerbeast11 is offline  
Old 24/08/2011, 12:56 AM   #5
Intoxicated
Big Clucker
 
Join Date: Nov 2010
Posts: 63
Reputation: 7
Default Re: Timer won't Countdown!!!

Quote:
Originally Posted by a_big View Post
I know this is off-topic but couldnt you use the game clock?
^^ That.

Just use TogglePlayerClock and use a timer to update the time every second or so.
Intoxicated is offline  
Old 24/08/2011, 12:59 AM   #6
Tigerbeast11
Gangsta
 
Join Date: Aug 2009
Posts: 771
Reputation: 2
Default Re: Timer won't Countdown!!!

Jefff: It still doesn't count down :/
Tigerbeast11 is offline  
Old 24/08/2011, 01:04 AM   #7
grand.Theft.Otto
High-roller
 
grand.Theft.Otto's Avatar
 
Join Date: Sep 2010
Location: Canada
Posts: 1,070
Reputation: 65
Default Re: Timer won't Countdown!!!

Quote:
Originally Posted by Intoxicated View Post
^^ That.

Just use TogglePlayerClock and use a timer to update the time every second or so.
Do you not get it? He said COUNTDOWN not the default GTA SA clock ..

Why not use gametext instead of textdraws? Then again other gametext may interfere with it.
__________________


grand.Theft.Otto is offline  
Old 24/08/2011, 01:05 AM   #8
Jefff
High-roller
 
Join Date: Dec 2007
Posts: 2,585
Reputation: 294
Default Re: Timer won't Countdown!!!

Where is TDShowFor ?
Jefff is online now  
Old 24/08/2011, 01:06 AM   #9
Tigerbeast11
Gangsta
 
Join Date: Aug 2009
Posts: 771
Reputation: 2
Default Re: Timer won't Countdown!!!

Under OnPlayerConnect

Code:
public OnPlayerConnect(playerid)
{
	TextDrawShowForPlayer(playerid, Textdraw0);
	return 1;
}
Tigerbeast11 is offline  
Old 24/08/2011, 01:10 AM   #10
grand.Theft.Otto
High-roller
 
grand.Theft.Otto's Avatar
 
Join Date: Sep 2010
Location: Canada
Posts: 1,070
Reputation: 65
Default Re: Timer won't Countdown!!!

Doubt this will work but, try setting it for max players:

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);
	    }
	    if(GameSeconds == 0 && GameMinutes == 0)
	    {
	        OnGameModeExit();
	    }
	}
    return 1;
}
__________________


grand.Theft.Otto 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 08:33 PM
[Help] Countdown timer in Textdraws Coldthug Help Archive 0 08/05/2010 01:16 PM
[SOLVED finaly :D] Really need help with countdown timer [HLF]Southclaw Help Archive 10 05/02/2010 04:39 PM
[SOLVED]Countdown Timer Tigerbeast11 Help Archive 11 24/11/2009 05:49 PM
Timer/Countdown/Million KyleLyndonSmith Help Archive 2 13/03/2009 11:29 AM


All times are GMT. The time now is 01:29 AM.


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