Jump to content

Countdown script!


Cyber

Recommended Posts

Hmm I guess it could be done very easily using setTimer and a recursive function with an argument containing how much secs are left and errmmm... if 0, print "GO!" or whatever LOL :D I don't know how to create a new command for usage in the console and I don't know how to print in the chat, but otherwise I'll write it for you LOL :P Damn lack of time ghehe

Link to comment

Hmmm.. to show you what I mean:

function countdown(count) 
    if (count > 0) then 
        outputChatBox(count, getRootElement(), 255, 255, 255) 
        setTimer(countdown(count - 1), 1000, 0) 
    else 
        outputChatBox("Go Go Go!!!", getRootElement(), 255, 255, 255) 
    end 
end 
  
addCommandHandler("countdown", countdown(5)) 

Remember, I don't know if it works, if it's correct and how to test it, it's just to give you a hand. Hope it works though, that would be nice ofcourse ;):lol: I'm particularily not sure about the parameters in the CommandHandler and in the Timer. Oh and I don't know how to do the ! command, so it now should work with a / hmmm...

Anywayz... another option is:

function countdownRec(count) 
    if (count > 0) then 
        outputChatBox(count, getRootElement(), 255, 255, 255) 
        setTimer(countdownRec(count - 1), 1000, 0) 
    else 
        outputChatBox("Go Go Go!!!", getRootElement(), 255, 255, 255) 
    end 
end 
  
function countdown() 
    countdownRec(5) 
end 
  
addCommandHandler("countdown", countdown) 

Let me know how it goes ;) My main concerns are using / instead of ! and using parameters :|

Link to comment

/me slaps Tubbie with "Btw: It's for MTA:SA RACE!"

on *:SIGNAL:mta.command:{ 
  if ($3 == !countdown) { 
    var %a = 1,%max = 6 
    while (%a <= %max) { 
      if (%a == %max) .timer 1 %a mta.text $1 Go Go Go!!! 
      else .timer 1 %a mta.text $1 %max - %a 
      !inc %a 
    } 
  } 
} 

Link to comment
just wondering, but was it correct for DM? ;)

dunno if the first one would of worked but either way I'd call the timer once instead of infinite times ;)

function countdown(count) 
    if (not count) then 
        count = 5 
    elseif (count > 0) then 
        outputChatBox(count, getRootElement(), 255, 255, 255) 
        setTimer(countdown(count - 1), 1000, 1) 
    else 
        outputChatBox("Go Go Go!!!", getRootElement(), 255, 255, 255) 
    end 
end 
  
addCommandHandler("countdown", countdown) 

this would work with no parameters ^

Link to comment

Hmm oh yes... so you cant give any parameters... that's annoying :-s but anyway, I don't think it got called infinite times ;) cuz when it reaches 0, it just puts something in the chat and there is no recursive call anymore LOL :D By the way, how can you create ! commands? Cuz this script creates a / command :D

Oh.. wait... I see what you mean with infinite... it's the 0 you replaced with a 1 right? LOLLLL nevermind :P

Link to comment

Oh i spotted a bug :lol:

Replace:

  
mta.text $1 4... 
mta.text $1 3... 
mta.text $1 2... 
mta.text $1 1... 
mta.text $1 Go Go Go!!!! 
} 

With:

  
mta.text  4... 
mta.text  3... 
mta.text  2... 
mta.text  1... 
mta.text  Go Go Go!!!! 
} 

So code looks like:

if ($3 == !countdown) mta.text $1 5... 
mta.text  4... 
mta.text  3... 
mta.text  2... 
mta.text  1... 
mta.text  Go Go Go!!!! 

lol, there you go :D:)

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...