Fix vote related bugs

* Reset playertag on new match
* Clear votes on new match
This commit is contained in:
ClobberXD 2018-08-20 15:53:42 +05:30 committed by rubenwardy
parent c1fe05b78f
commit 72c5afab55
5 changed files with 28 additions and 7 deletions

View file

@ -40,6 +40,8 @@ function ctf_match.vote_next(name, params)
})
end
ctf_match.register_on_new_match(vote.clear_vote)
minetest.register_chatcommand("vote", {
privs = {
interact = true,

View file

@ -70,6 +70,14 @@ function playertag.set(player, type, color)
end
end
function playertag.get(player)
return tag_settings[player:get_player_by_name()]
end
function playertag.get_all()
return tag_settings
end
local nametag = {
npcf_id = "nametag",
physical = false,

View file

@ -1 +1,2 @@
ctf_flag
ctf_match

View file

@ -12,3 +12,11 @@ end)
ctf_flag.register_on_capture(function(attname, flag)
playertag.set(minetest.get_player_by_name(attname), playertag.TYPE_ENTITY)
end)
ctf_match.register_on_new_match(function()
for name, settings in pairs(playertag.get_all()) do
if settings.type == playertag.TYPE_BUILTIN then
playertag.set(minetest.get_player_by_name(name), playertag.TYPE_ENTITY)
end
end
end)

View file

@ -146,15 +146,17 @@ minetest.register_privilege("vote_admin", {
description = "Allows a player to manage running votes."
})
function vote.clear()
vote.active = {}
vote.queue = {}
vote.update_all_hud()
end
minetest.register_chatcommand("vote_clear", {
privs = {
vote_admin = true,
},
func = function(name, params)
vote.active = {}
vote.queue = {}
vote.update_all_hud()
end
func = vote.clear
})
local hudkit = dofile(minetest.get_modpath("vote") .. "/hudkit.lua")
@ -229,7 +231,7 @@ minetest.register_privilege("vote", {
})
minetest.register_privilege("vote_starter", {
description = "Can vote on issues",
description = "Can start votes on issues",
basic_priv = true
})