• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Nice and easy way to script a countdown?
#1
What do you reckon that would be an efficient method of implementing a countdown (a few minutes long), including both a timer and an updating TextDraw or GameText?



Afterwards, how would you be able to script something to happen at the end of it?



Cheers!
  Reply
#2
I've been doing it like this:

Code:
timer Countdown[1000](playerid, seconds)
{
    if (seconds) {
        defer Countdown(playerid, --seconds);
        // Update GameText, be aware that seconds is already subtracted by 1
    }
    else {
        // Timer finished, code;
    }
}
Dunno if it's the best way but I hope that I gave you a good idea how :3
Using Pawn.CMD?

If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
  Reply
#3
Thank you, Pinch. Please take into account that I am quite new to scripting and frankly the first line of your code is unclear to me. Is that basically a function that I should call whenever I will want to initiate a countdown?
  Reply
#4
Yes, if you're using y_timers just do Countdown(playerid, seconds);
Using Pawn.CMD?

If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
  Reply
#5
(2021-01-14, 02:44 PM)Pinch Wrote: Yes, if you're using y_timers just do Countdown(playerid, seconds);

If I don't use y_timers then will this works like this?:
Countdown(playerid, 11); 
or this:
Countdown[1000](playerid, 11);
  Reply


Forum Jump: