Ingoring some players (e.g. bots)
This commit is contained in:
parent
d3a282b42f
commit
64fa36a0d8
39
init.lua
39
init.lua
@ -110,8 +110,19 @@ end
|
|||||||
function vote.check_vote(voteset)
|
function vote.check_vote(voteset)
|
||||||
local all_players_voted = true
|
local all_players_voted = true
|
||||||
local players = minetest.get_connected_players()
|
local players = minetest.get_connected_players()
|
||||||
|
local ignored_players = core.get_mod_storage():get_string("ignored_players"):split(" ")
|
||||||
for _, player in pairs(players) do
|
for _, player in pairs(players) do
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
local is_ignored = false
|
||||||
|
for _, ignored_name in ipairs(ignored_players) do
|
||||||
|
if name == ignored_name then
|
||||||
|
is_ignored = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if is_ignored then
|
||||||
|
break
|
||||||
|
end
|
||||||
if not voteset.results.voted[name] then
|
if not voteset.results.voted[name] then
|
||||||
all_players_voted = false
|
all_players_voted = false
|
||||||
break
|
break
|
||||||
@ -289,3 +300,31 @@ minetest.register_chatcommand("abstain", {
|
|||||||
vote.check_vote(voteset)
|
vote.check_vote(voteset)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_chatcommand("vote_ignored", {
|
||||||
|
privs = {
|
||||||
|
vote_admin = true,
|
||||||
|
},
|
||||||
|
description = "Get a list of players ignored during voting",
|
||||||
|
func = function(name, params)
|
||||||
|
minetest.chat_send_player(
|
||||||
|
name,
|
||||||
|
"Ignored players: " .. core.get_mod_storage():get_string("ignored_players")
|
||||||
|
)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_chatcommand("vote_ignore", {
|
||||||
|
privs = {
|
||||||
|
vote_admin = true,
|
||||||
|
},
|
||||||
|
description = "Ignore player(s) during voting",
|
||||||
|
params = "<PlayerName>...",
|
||||||
|
func = function(name, params)
|
||||||
|
local meta = core.get_mod_storage()
|
||||||
|
meta:set_string(
|
||||||
|
"ignored_players",
|
||||||
|
meta:get_string("ignored_players") .. params
|
||||||
|
)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user