mirror of
https://github.com/a-bad-dev/simple-shooter-game.git
synced 2026-06-09 20:36:15 +00:00
Fix countdown persisting after aborting
This commit is contained in:
parent
98d712e860
commit
402f1ec7ca
1 changed files with 14 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
match_start_job = nil
|
match_start_jobs = {}
|
||||||
loading_tips = {
|
loading_tips = {
|
||||||
"Open the inventory to change class!",
|
"Open the inventory to change class!",
|
||||||
"Short-range is good for small/dense maps!",
|
"Short-range is good for small/dense maps!",
|
||||||
|
|
@ -177,21 +177,21 @@ function start_match(map) -- Start the match
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if map_data.on_start then
|
if map_data.on_start then
|
||||||
map_data.on_start()
|
map_data.on_start()
|
||||||
end
|
end
|
||||||
|
|
||||||
core.chat_send_all(core.colorize("#b011f9", string.format("Match about to start in %d seconds!\nOpen inventory to change class!", map_data.start_time)))
|
core.chat_send_all(core.colorize("#b011f9", string.format("Match about to start in %d seconds!\nOpen inventory to change class!", map_data.start_time)))
|
||||||
|
|
||||||
|
match_start_jobs.countdown = {}
|
||||||
for i = 10, 1, -1 do -- count down from 10 to 1 (yes you are free to set me on fire for this horrible solution)
|
for i = 10, 1, -1 do -- count down from 10 to 1 (yes you are free to set me on fire for this horrible solution)
|
||||||
core.after(map_data.start_time - 10 + i, function()
|
table.insert(match_start_jobs.countdown, core.after(map_data.start_time - 10 + i, function()
|
||||||
core.chat_send_all(core.colorize("green", string.format("Match starts in %d second%s.", 11 - i, 11 - i == 1 and "" or "s"))) -- <- RIP readability
|
core.chat_send_all(core.colorize("green", string.format("Match starts in %d second%s.", 11 - i, 11 - i == 1 and "" or "s"))) -- <- RIP readability
|
||||||
end)
|
end))
|
||||||
end
|
end
|
||||||
|
|
||||||
match_start_job = core.after(map_data.start_time, function()
|
match_start_jobs.map = core.after(map_data.start_time, function()
|
||||||
match_start_job = nil
|
match_start_jobs = {}
|
||||||
set_match_state("in_progress")
|
set_match_state("in_progress")
|
||||||
core.chat_send_all(core.colorize("green", "Match started!"))
|
core.chat_send_all(core.colorize("green", "Match started!"))
|
||||||
|
|
||||||
|
|
@ -221,8 +221,14 @@ end
|
||||||
function end_match() -- End the match
|
function end_match() -- End the match
|
||||||
set_match_state("not_started")
|
set_match_state("not_started")
|
||||||
|
|
||||||
if match_start_job ~= nil then
|
if match_start_job ~= {} then
|
||||||
match_start_job:cancel()
|
match_start_jobs.map:cancel()
|
||||||
|
|
||||||
|
for _, job in pairs(match_start_jobs.countdown) do
|
||||||
|
job:cancel()
|
||||||
|
end
|
||||||
|
|
||||||
|
match_start_jobs = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
if map_data.on_end then
|
if map_data.on_end then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue