pro-mos Posted February 24, 2016 Posted February 24, 2016 (edited) function countDown(player, _, limit) for i = 1, limit, 1 do if i ~= limit then msg("[Count Down] " ..i, root) else msg("[Count Down] GO GO GO", root, 255,255,0) end end end addCommandHandler("c", countDown) i cant get the else statement to work, its supposed to print "GO" instead of the last limit number UPDATE: no errors Edited February 24, 2016 by Guest
SpecT Posted February 24, 2016 Posted February 24, 2016 This should work: function countDown(player, _, limit) for i = 1, limit do if i ~= limit then msg("[Count Down] " ..i, root) else msg("[Count Down] GO GO GO", root, 255,255,0) end end end addCommandHandler("c", countDown)
pro-mos Posted February 24, 2016 Author Posted February 24, 2016 This should work: function countDown(player, _, limit) for i = 1, limit do if i ~= limit then msg("[Count Down] " ..i, root) else msg("[Count Down] GO GO GO", root, 255,255,0) end end end addCommandHandler("c", countDown) no it doesnt
SpecT Posted February 24, 2016 Posted February 24, 2016 I just tested it and it worked fine. Don't forget to type the limit when you use the command !!!
pro-mos Posted February 24, 2016 Author Posted February 24, 2016 I just tested it and it worked fine. Don't forget to type the limit when you use the command !!! its not that different from my code.. it only prints the first if statment, and never prints whats inside else "GO GO GO"
SpecT Posted February 24, 2016 Posted February 24, 2016 (edited) Oh, my bad. I didn't get you the first time. There you go: function countDown(player, _, limit) local limit = tonumber(limit)+1 for i = 1, limit do if i < limit then msg("[Count Down] " ..i, root) else msg("[Count Down] GO GO GO", root, 255,255,0) end end end addCommandHandler("c", countDown) BTW it would be better if you make it with timer (per 1 second). Good luck! Edited February 24, 2016 by Guest
pro-mos Posted February 24, 2016 Author Posted February 24, 2016 thanks, didn't know i have to convert limit to a number..
Bonus Posted February 24, 2016 Posted February 24, 2016 local limit = tonumber(limit)+1 That is better But care: The countdown will finish in under 50 milliseconds.
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