Fix vote related bugs
* Reset playertag on new match * Clear votes on new match
This commit is contained in:
parent
c1fe05b78f
commit
72c5afab55
5 changed files with 28 additions and 7 deletions
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
ctf_flag
|
||||
ctf_match
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -146,15 +146,17 @@ minetest.register_privilege("vote_admin", {
|
|||
description = "Allows a player to manage running votes."
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("vote_clear", {
|
||||
privs = {
|
||||
vote_admin = true,
|
||||
},
|
||||
func = function(name, params)
|
||||
function vote.clear()
|
||||
vote.active = {}
|
||||
vote.queue = {}
|
||||
vote.update_all_hud()
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("vote_clear", {
|
||||
privs = {
|
||||
vote_admin = true,
|
||||
},
|
||||
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
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue