From 08bc2ab8a2be46733a403b11be63f3af3dd41996 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Wed, 26 Aug 2015 16:12:19 +0100 Subject: [PATCH] Disable kick voting with a setting --- init.lua | 77 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/init.lua b/init.lua index 78e5243..c311e22 100644 --- a/init.lua +++ b/init.lua @@ -275,41 +275,44 @@ minetest.register_chatcommand("abstain", { end }) -minetest.register_chatcommand("vote_kick", { - privs = { - interact = true - }, - func = function(name, param) - if not minetest.get_player_by_name(param) then - minetest.chat_send_player(name, "There is no player called '" .. - param .. "'") - return - end - - vote.new_vote(name, { - description = "Kick " .. param, - help = "/yes, /no or /abstain", - name = param, - duration = 60, - perc_needed = 0.8, - - on_result = function(self, result, results) - if result == "yes" then - minetest.chat_send_all("Vote passed, " .. - #results.yes .. " to " .. #results.no .. ", " .. - self.name .. " will be kicked.") - minetest.kick_player(self.name, "The vote to kick you passed") - else - minetest.chat_send_all("Vote failed, " .. - #results.yes .. " to " .. #results.no .. ", " .. - self.name .. " remains ingame.") - end - end, - - on_vote = function(self, name, value) - minetest.chat_send_all(name .. " voted " .. value .. " to '" .. - self.description .. "'") +local set = minetest.setting_get("vote.kick_vote") +if set == nil or minetest.is_yes(set) then + minetest.register_chatcommand("vote_kick", { + privs = { + interact = true + }, + func = function(name, param) + if not minetest.get_player_by_name(param) then + minetest.chat_send_player(name, "There is no player called '" .. + param .. "'") + return end - }) - end -}) + + vote.new_vote(name, { + description = "Kick " .. param, + help = "/yes, /no or /abstain", + name = param, + duration = 60, + perc_needed = 0.8, + + on_result = function(self, result, results) + if result == "yes" then + minetest.chat_send_all("Vote passed, " .. + #results.yes .. " to " .. #results.no .. ", " .. + self.name .. " will be kicked.") + minetest.kick_player(self.name, "The vote to kick you passed") + else + minetest.chat_send_all("Vote failed, " .. + #results.yes .. " to " .. #results.no .. ", " .. + self.name .. " remains ingame.") + end + end, + + on_vote = function(self, name, value) + minetest.chat_send_all(name .. " voted " .. value .. " to '" .. + self.description .. "'") + end + }) + end + }) +end