Countdown - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Countdown (
/showthread.php?tid=257804)
Countdown -
Markx - 27.05.2011
Is there any kind of a function that could count down from 3 mins in textdraw? Like over the hud? I really need it but dont have a idea how to make it. And also make something when its over.. Please. Didnt find anything on search and ****** :/
Re: Countdown -
Seven_of_Nine - 27.05.2011
pawn Код:
//Global
new Text:draw1;
//OnGameModeInit
draw1 = TextDrawCreate(0,0,"default");
//Global
new Text:draw2;
//OnGameModeInit
draw2 = TextDrawCreate(0,0,"default");
//Global
new Mins = 3;
//config of textdraw [...]
forward Minute();
public Minute() {
for(new i = 60; i > 0; i--;) {
TextDrawHideForAll(draw1);
new ts[10];
valstr(ts,i);
TextDrawHideForAll(draw1);
TextDrawSetString(draw1,ts);
TextDrawShowForAll(draw1);
}
return 1;
}
forward Decrease();
public Decrease() {
Mins--;
new ts[10];
valstr(ts,Mins);
format(ts,sizeof(ts),"%s:",ts);
TextDrawHideForAll(draw2);
if(Mins == 0) {
TextDrawHideForAll(draw1);
return MyFunc();
}
TextDrawSetString(draw2,ts);
TextDrawShowForAll(draw2);
return 1;
}
If it isn't working, then I think you can fix it.
Re: Countdown -
Markx - 27.05.2011
Quote:
Originally Posted by Seven_of_Nine
pawn Код:
//Global new Text:draw1; //OnGameModeInit draw1 = TextDrawCreate(0,0,"default"); //Global new Text:draw2; //OnGameModeInit draw2 = TextDrawCreate(0,0,"default"); //Global new Mins = 3; //config of textdraw [...]
forward Minute(); public Minute() { for(new i = 60; i > 0; i--;) { TextDrawHideForAll(draw1); new ts[10]; valstr(ts,i); TextDrawHideForAll(draw1); TextDrawSetString(draw1,ts); TextDrawShowForAll(draw1); } return 1; } forward Decrease(); public Decrease() { Mins--; new ts[10]; valstr(ts,Mins); format(ts,sizeof(ts),"%s:",ts); TextDrawHideForAll(draw2); if(Mins == 0) { TextDrawHideForAll(draw1); return MyFunc(); } TextDrawSetString(draw2,ts); TextDrawShowForAll(draw2); return 1; }
If it isn't working, then I think you can fix it. :)
|
How about making it 3:00 [mins:secs]
How would that go?
Re: Countdown -
Seven_of_Nine - 27.05.2011
That is Mins:Seconds. But a little bit formatted..
Just fix the errors (I didn't test it) and it'll work. (I think..)
Re: Countdown -
BigETI - 27.05.2011
pawn Код:
#define MAX_TIME 180 //Add here your time in seconds. 180 seconds/60 seconds per minute makes 3 minutes
new Text:TimeText, ticked, countdowntimer;
forward Tick();
public Tick()
{
ticked++;
new ticktime = MAX_TIME-ticked, tempticktime = ticktime, minutes = 0;
while(tempticktime > 59)
{
minutes++;
tempticktime = tempticktime-60;
}
format(str, sizeof(str), "%02d:%02d", minutes, tempticktime);
TextDrawSetString(TimeText, str);
if(ticktime == 0)
{
KillTimer(countdowntimer);
//Do here your things when the time end.
}
}
public OnGameModeInit()
{
TimeText = TextDrawCreate(550.0, 33.0, "--:--");
new ticktime = MAX_TIME, minutes = 0;
while(ticktime > 59)
{
minutes++;
ticktime = ticktime-60;
}
new str[128];
format(str, sizeof(str), "%02d:%02d", minutes, ticktime);
TextDrawSetString(TimeText, str);
countdowntimer = SetTimer("Tick", 1000, true);
return 1;
}
public OnPlayerConnect(playerid)
{
TextDrawShowForPlayer(playerid, TimeText);
return 1;
}
Re: Countdown -
Markx - 28.05.2011
Quote:
Originally Posted by BigETI
pawn Код:
#define MAX_TIME 180 //Add here your time in seconds. 180 seconds/60 seconds per minute makes 3 minutes
new Text:TimeText, ticked, countdowntimer;
forward Tick();
public Tick() { ticked++; new ticktime = MAX_TIME-ticked, tempticktime = ticktime, minutes = 0; while(tempticktime > 59) { minutes++; tempticktime = tempticktime-60; } format(str, sizeof(str), "%02d:%02d", minutes, tempticktime); TextDrawSetString(TimeText, str); if(ticktime == 0) { KillTimer(countdowntimer); //Do here your things when the time end. } }
public OnGameModeInit() { TimeText = TextDrawCreate(550.0, 33.0, "--:--"); new ticktime = MAX_TIME, minutes = 0; while(ticktime > 59) { minutes++; ticktime = ticktime-60; } new str[128]; format(str, sizeof(str), "%02d:%02d", minutes, ticktime); TextDrawSetString(TimeText, str); countdowntimer = SetTimer("Tick", 1000, true); return 1; }
public OnPlayerConnect(playerid) { TextDrawShowForPlayer(playerid, TimeText); return 1; }
|
Fucking awesome dude, you got credits :)
Re: Countdown -
cs_master - 28.05.2011
Quote:
//=====================forwords
forward DMTimer(playerid);
//==============================[Others]========================================
new DMTime;
new dmtimer;
//================================================== ============================
public OnGameModeInit()
{
DMTime = 300; // change time that show in ur textdraw here i add 5 mints
//=============================[Timers]=========================================
dmtimer = SetTimer("DMTimer", 300, 1);
return 1;
}
//================================================== ============================
public DMTimer()
{
DMTime --;
new tmp[256];
format(tmp, sizeof tmp, "%s", TimeConvert(DMTime));
TextDrawSetString(Text:Time, tmp);
TextDrawShowForAll(Text:Time);
}
return 1;
}
|
working code 10/10
Re: Countdown -
BigETI - 28.05.2011
Quote:
Originally Posted by Markx
Fucking awesome dude, you got credits ![Smiley](images/smilies/smile.png)
|
Thanks