diff --git a/mods/ctf_match/vote.lua b/mods/ctf_match/vote.lua index f431997..20633dc 100644 --- a/mods/ctf_match/vote.lua +++ b/mods/ctf_match/vote.lua @@ -7,7 +7,7 @@ function ctf_match.register_on_skip_map(func) end function ctf_match.vote_next(name, params) - vote.new_vote(name, { + return vote.new_vote(name, { description = "Skip to next match", help = "/yes, /no or /abstain", duration = 60, @@ -44,7 +44,10 @@ minetest.register_chatcommand("vote", { minetest.register_on_chat_message(function(name, msg) if msg == "/vote_next" then - ctf_match.vote_next(name) + local suc, msg = ctf_match.vote_next(name) + if msg then + minetest.chat_send_player(name, msg) + end return true end end) diff --git a/mods/vote/init.lua b/mods/vote/init.lua index 9659273..a9163ff 100644 --- a/mods/vote/init.lua +++ b/mods/vote/init.lua @@ -5,16 +5,19 @@ vote = { function vote.new_vote(creator, voteset) local max_votes = tonumber(minetest.setting_get("vote.maximum_active")) or 1 + local max_queue = tonumber(minetest.setting_get("vote.maximum_active")) or 0 if #vote.active < max_votes then vote.start_vote(voteset) - else + return true, "Vote Started. You still need to vote: " .. voteset.help + elseif max_queue == 0 then + return false, "A vote is already running, please try again later." + elseif #vote.queue < max_queue then table.insert(vote.queue, voteset) - if creator then - minetest.chat_send_player(creator, - "Vote queued until there is less then " .. max_votes .. - " votes active.") - end + return true, "Vote queued until there is less then " .. max_votes .. + " votes active." + else + return false, "The queue of votes waiting to run is full. Please try again later." end end @@ -303,7 +306,7 @@ if set == nil or minetest.is_yes(set) then return end - vote.new_vote(name, { + return vote.new_vote(name, { description = "Kick " .. param, help = "/yes, /no or /abstain", name = param,