Countdown TextDraw bugged. -
Dex007HLH - 16.02.2013
I've got this, and it works fine for player id 0 but when somebody else enters the server the textdraw gets stuck in 5:00.
Code:
new Minutes =4;
new Seconds =59;
new Text:Timeleft [MAX_PLAYERS];
forward GameTime(playerid);
Code:
OnGameModeInit()
SetTimer("GameTime",1000,1);
Timeleft[playerid] = TextDrawCreate(59.000000, 320.000000, "5:00");
TextDrawBackgroundColor(Timeleft[playerid], 255);
TextDrawFont(Timeleft[playerid], 1);
TextDrawLetterSize(Timeleft[playerid], 0.509999, 1.900000);
TextDrawColor(Timeleft[playerid], -1);
TextDrawSetOutline(Timeleft[playerid], 1);
TextDrawSetProportional(Timeleft[playerid], 1);
Code:
OnPlayerSpawn
TextDrawShowForPlayer(playerid, Timeleft[playerid]);
Code:
public GameTime(playerid)
{
if(Seconds || Minutes) {
Seconds--;
if(Seconds <= -1) {
Minutes--;
Seconds=59;
}
new TimeString[128];
format(TimeString,sizeof(TimeString),"%02d:%02d",Minutes,Seconds);
TextDrawSetString(Timeleft[playerid],TimeString);
}
return 1;
}
Re: Countdown TextDraw bugged. -
Luis- - 16.02.2013
Could be because of this
Timeleft[playerid] if it's meant to be a global textdraw you should remove the [playerid] part and just have it as
Timeleft.
Respuesta: Re: Countdown TextDraw bugged. -
Dex007HLH - 16.02.2013
Quote:
Originally Posted by -Luis
Could be because of this Timeleft[playerid] if it's meant to be a global textdraw you should remove the [playerid] part and just have it as Timeleft.
|
For some reason textdraws without the [playerid] thingie are not showing up in my server
Re: Countdown TextDraw bugged. -
RajatPawar - 16.02.2013
pawn Code:
new Text:Yourtextdraw
CMD:countdown(playerid, params[])
{
new number;
if(sscanf(params,"d",start)) return SCM(...)
YourTextdraw = TextdrawCreate( .... number)
TextDrawShowForAll(...);
SetTimerEx("Countdown",1000,1,"d",number);
return 1;
}
forward public Countdown(number);
public Countdown(number)
{
TextDrawSetString(YourTextDraw, number - 1);
TextDrawShowForAll(..);
number -= 1;
return 1;
}
Try a code like this? I don't know if it may work, check it out.
Respuesta: Re: Countdown TextDraw bugged. -
Dex007HLH - 16.02.2013
Quote:
Originally Posted by -Luis
Could be because of this Timeleft[playerid] if it's meant to be a global textdraw you should remove the [playerid] part and just have it as Timeleft.
|
Quote:
Originally Posted by Rajat_Pawar
pawn Code:
new Text:Yourtextdraw CMD:countdown(playerid, params[]) { new number; if(sscanf(params,"d",start)) return SCM(...) YourTextdraw = TextdrawCreate( .... number) TextDrawShowForAll(...); SetTimerEx("Countdown",1000,1,"d",number); return 1; } forward public Countdown(number); public Countdown(number) { TextDrawSetString(YourTextDraw, number - 1); TextDrawShowForAll(..); number -= 1; return 1; }
Try a code like this? I don't know if it may work, check it out.
|
That's not what I'm looking for, that's a countdown command, mine is some kind of "watch"
Re: Countdown TextDraw bugged. -
RajatPawar - 16.02.2013
Alright. You are trying to use a player variable (MAX_PLAYERS) as a Textdraw. Use a PlayerTextDraw.
Respuesta: Re: Countdown TextDraw bugged. -
Dex007HLH - 16.02.2013
Quote:
Originally Posted by Rajat_Pawar
Alright. You are trying to use a player variable (MAX_PLAYERS) as a Textdraw. Use a PlayerTextDraw.
|
What's the point of replacing it with PlayerTextDraw if the effects are the same?
Re: Countdown TextDraw bugged. -
RajatPawar - 16.02.2013
LOL, I got your problem. Sorry I didn't get it first.
You are trying to set a timer with a playerid argument in it with SetTimer, which is impossible.
For setting a timer with a function which has it's arguments/parameters, the format is:
pawn Code:
SetTimerEx("MyFunction", Time, Repeating, "Specifier of the argument", Argument name...);
//In your case, it would be:
SetTimerEx("Gametime", 1000, 1, "d", playerid);
Respuesta: Re: Countdown TextDraw bugged. -
Dex007HLH - 16.02.2013
Quote:
Originally Posted by Rajat_Pawar
LOL, I got your problem. Sorry I didn't get it first.
You are trying to set a timer with a playerid argument in it with SetTimer, which is impossible.
For setting a timer with a function which has it's arguments/parameters, the format is:
pawn Code:
SetTimerEx("MyFunction", Time, Repeating, "Specifier of the argument", Argument name...); //In your case, it would be: SetTimerEx("Gametime", 1000, 1, "d", playerid);
|
There is not "playerid" on "ongamemodeinit" so how do I do that?
Re: Countdown TextDraw bugged. -
RajatPawar - 16.02.2013
You are telling the compiler that a function called 'Gametime' should be executed every second. But to show it to a player, there needs to be a 'playerid' parameter. So:
Instead of "SetTimer("GameTime", 1000, 1) under OnGameModeInIt,
replace it with:
Quote:
SetTimerEx("Gametime", 1000, 1, "d", playerid);
|