Disable kick voting by default

This commit is contained in:
rubenwardy 2015-09-01 18:22:34 +01:00
parent 100aa81a4f
commit c132ffda60
2 changed files with 44 additions and 49 deletions

View file

@ -2,6 +2,7 @@ give_initial_stuff = true
enable_pvp = true enable_pvp = true
fixed_map_seed = 14703851313754985906 fixed_map_seed = 14703851313754985906
map_generation_limit = 160 map_generation_limit = 160
vote.kick_vote = false
# See mods/ctf_pvp_engine/minetest.conf.example for ctf_pvp_engine settings. # See mods/ctf_pvp_engine/minetest.conf.example for ctf_pvp_engine settings.
ctf.flag.capture_take = true ctf.flag.capture_take = true

View file

@ -72,20 +72,11 @@ function vote.end_vote(voteset)
elseif voteset.results.yes and voteset.results.no then elseif voteset.results.yes and voteset.results.no then
local total = #voteset.results.yes + #voteset.results.no local total = #voteset.results.yes + #voteset.results.no
local perc_needed = voteset.perc_needed or 0.5 local perc_needed = voteset.perc_needed or 0.5
local unanimous = voteset.unanimous or 0
if total <= unanimous then if #voteset.results.yes / total > perc_needed then
if #voteset.results.no == 0 then result = "yes"
result = "yes"
else
result = "no"
end
else else
if #voteset.results.yes / total > perc_needed then result = "no"
result = "yes"
else
result = "no"
end
end end
end end
@ -284,41 +275,44 @@ minetest.register_chatcommand("abstain", {
end end
}) })
minetest.register_chatcommand("vote_kick", { local set = minetest.setting_get("vote.kick_vote")
privs = { if set == nil or minetest.is_yes(set) then
interact = true minetest.register_chatcommand("vote_kick", {
}, privs = {
func = function(name, param) interact = true
if not minetest.get_player_by_name(param) then },
minetest.chat_send_player(name, "There is no player called '" .. func = function(name, param)
param .. "'") if not minetest.get_player_by_name(param) then
return minetest.chat_send_player(name, "There is no player called '" ..
end param .. "'")
return
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 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