Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] Nice and easy way to script a countdown?

 
  • 0 Vote(s) - 0 Average
Pawn Nice and easy way to script a countdown?
M.D.
Offline

Burgershot Member
Posts: 5
Threads: 2
Joined: May 2020
Reputation: 0
#1
2021-01-12, 08:45 PM
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!
Pinch
Offline

Burgershot Member
Posts: 256
Threads: 18
Joined: Apr 2019
Reputation: 17
Location: Belgrade, Serbia
#2
2021-01-12, 11:19 PM (This post was last modified: 2021-01-12, 11:20 PM by Pinch.)
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.
M.D.
Offline

Burgershot Member
Posts: 5
Threads: 2
Joined: May 2020
Reputation: 0
#3
2021-01-13, 06:21 PM
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?
Pinch
Offline

Burgershot Member
Posts: 256
Threads: 18
Joined: Apr 2019
Reputation: 17
Location: Belgrade, Serbia
#4
2021-01-14, 02:44 PM
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.
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode