Cyber Posted February 8, 2008 Share Posted February 8, 2008 Could someone please write a !countdown script for me? It should look like this: Cyber says: !countdown 5 4 3 2 1 Go Go Go!!! Btw: It's for MTA:SA RACE! Thank you! Link to comment
Tubbie Posted February 8, 2008 Share Posted February 8, 2008 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 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 Damn lack of time ghehe Link to comment
Tubbie Posted February 8, 2008 Share Posted February 8, 2008 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 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
lil Toady Posted February 9, 2008 Share Posted February 9, 2008 /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
Cyber Posted February 9, 2008 Author Share Posted February 9, 2008 Thank You lil Toady! Link to comment
Tubbie Posted February 9, 2008 Share Posted February 9, 2008 DOH! I feel stupid Hmm... just wondering, but was it correct for DM? Link to comment
norby89 Posted February 9, 2008 Share Posted February 9, 2008 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
Tubbie Posted February 10, 2008 Share Posted February 10, 2008 Hmm oh yes... so you cant give any parameters... that's annoying 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 By the way, how can you create ! commands? Cuz this script creates a / command Oh.. wait... I see what you mean with infinite... it's the 0 you replaced with a 1 right? LOLLLL nevermind Link to comment
-XIII-4Cazp.UK Posted February 12, 2008 Share Posted February 12, 2008 Hope this is easier: if ($3 == !countdown) mta.text $1 5... mta.text $1 4... mta.text $1 3... mta.text $1 2... mta.text $1 1... mta.text $1 Go Go Go!!!! } dont excpect it to work lol, i dont test half the little scripts i make Link to comment
-XIII-4Cazp.UK Posted February 12, 2008 Share Posted February 12, 2008 Oh i spotted a bug 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 Link to comment
lil Toady Posted February 12, 2008 Share Posted February 12, 2008 1. No, the first script you posted was right, the second is not 2. You have no timer in the script, it will all be posted in the same second 3. I've already posted the countdown script Link to comment
-XIII-4Cazp.UK Posted February 13, 2008 Share Posted February 13, 2008 lol sry, i was tired when i made it Didnt read the other posts Link to comment
Recommended Posts