jkub Posted August 24, 2008 Share Posted August 24, 2008 Can someone please give me a countdown script... like one for a race. and the command to start it would be /count like 5 4 3 2 1 GO! Link to comment
Gamesnert Posted August 24, 2008 Share Posted August 24, 2008 Can someone please give me a countdown script... like one for a race.and the command to start it would be /count like 5 4 3 2 1 GO! count=5 function countdown() if count>0 then outputChatBox(count .. "") count=count-1 setTimer(count,1000,1) else outputChatBox("GOOO!!!") end end (not tested) Link to comment
haybail Posted August 25, 2008 Share Posted August 25, 2008 You didn't add the commandHandler and you forgot to reset count Might want to also make it so only one count can be running at a time, so it doesn't mess up the variable. Nice script otherwise Link to comment
DakiLLa Posted August 25, 2008 Share Posted August 25, 2008 try this: function countdownRec(count) if (count > 0) then outputChatBox(tostring(count), getRootElement(), 255, 255, 255) setTimer(countdownRec, 1000, 1, count-1) else outputChatBox("Go Go Go!!!", getRootElement(), 255, 255, 255) end end function countdown() countdownRec(5) end addCommandHandler("count", countdown) Link to comment
Ace_Gambit Posted August 25, 2008 Share Posted August 25, 2008 Or you can try this if you like a cool text display . This also makes sure you can't initiate a count down when one is still running. local root = getRootElement() local count = 0 local billboard = false local numbers = false local timer = false function isTimer(theTimer) for _, pTimer in ipairs(getTimers(2500)) do if (pTimer == theTimer) then return true end end return false end function countClean() for _, player in ipairs(getElementsByType("player", root)) do textDisplayRemoveObserver(billboard, player) end textDestroyTextItem(numbers) textDestroyDisplay(billboard) billboard, numbers = false, false count = 0 end function playSoundForAll(sound) for _, player in ipairs(getElementsByType("player", root)) do playSoundFrontEnd(player, sound) end end function countStart() if (count == 5) then billboard = textCreateDisplay() numbers = textCreateTextItem("", 0.5, 0.5) if (billboard and numbers) then textItemSetScale(numbers, 2.5) textItemSetPriority(numbers, "high") textDisplayAddText(billboard, numbers) for _, player in ipairs(getElementsByType("player", root)) do textDisplayAddObserver(billboard, player) end end end if (billboard and numbers) then if (count == 0) then count = -1 textItemSetText(numbers, "GO!") playSoundForAll(45) timer = setTimer(countClean, 2500, 1) end if (count > 0) then textItemSetText(numbers, tostring(count)) playSoundForAll(43) count = count - 1 timer = setTimer(countStart, 1000, 1) end end end function checkState(playerSource, commandName) if (string.lower(commandName) == "/count" and count == 0 and not isTimer(timer)) then if (playerSource) then outputChatBox("* Countdown initiated by " .. getClientName(playerSource)) end count = 5 countStart() end end addCommandHandler("/count", checkState, false) Link to comment
jkub Posted August 26, 2008 Author Share Posted August 26, 2008 Hey ace i tried your script and i couldent get it to work. Ive looked at some stuff myself even though I dont much myself but thank you so much guys. Ive been lookin for this a while : Link to comment
Ace_Gambit Posted August 27, 2008 Share Posted August 27, 2008 That is strange because I did test it and it worked. Don't forget it's server side code. Link to comment
jkub Posted August 27, 2008 Author Share Posted August 27, 2008 k im gonna try it agin.. hope it works Link to comment
Ace_Gambit Posted August 27, 2008 Share Posted August 27, 2008 (edited) Maybe it's conflicting with another resource. I dunno lol. Really that should work. I double checked...no, I even triple checked. Edited August 27, 2008 by Guest Link to comment
jkub Posted August 27, 2008 Author Share Posted August 27, 2008 k ill look some more... Ive looked at the wiki for hours and still dont get anything. Ive even tryed doing everything step by step but I was successful at nothing. the wiki is confusing>>//?? Link to comment
haybail Posted August 27, 2008 Share Posted August 27, 2008 Which part did you get to where it doesn't work? Maybe ace can put it in a zip so you can just put it in the right folder and do /start run. Link to comment
jkub Posted August 27, 2008 Author Share Posted August 27, 2008 when I typed in the command it wouldent do anything? im gonna check the command handler Link to comment
Gamesnert Posted August 27, 2008 Share Posted August 27, 2008 when I typed in the command it wouldent do anything? im gonna check the command handler If you did it in another file, be sure you added that to the meta.xml. Link to comment
Guest Posted September 14, 2008 Share Posted September 14, 2008 } elseif (!count* iswm $3) { mta.text $1 Countdown: 3... .timer 1 2 mta.text $1 Countdown: 2... .timer 1 4 mta.text $1 Countdown: 1... .timer 1 6 mta.text $1 Countdown: Go Go Go!!! i have this and it works on my server hope it helps Link to comment
50p Posted September 14, 2008 Share Posted September 14, 2008 } elseif (!count* iswm $3) { mta.text $1 Countdown: 3... .timer 1 2 mta.text $1 Countdown: 2... .timer 1 4 mta.text $1 Countdown: 1... .timer 1 6 mta.text $1 Countdown: Go Go Go!!! i have this and it works on my server hope it helps It looks like IRC script... this section of forum deals with Lua. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now