Fix bounty loopholes

This commit is contained in:
ClobberXD 2018-12-31 04:57:16 +05:30 committed by rubenwardy
parent cdef72cf5d
commit bb260b2274

View file

@ -21,10 +21,7 @@ local function announce_all()
end
local function bounty_player(target)
if bountied_player then
minetest.chat_send_all("Player " .. bountied_player .. " no longer has a bounty on their head!")
end
local prev = bountied_player
bountied_player = target
-- Score * K/D
@ -44,6 +41,19 @@ local function bounty_player(target)
end
bounty_score = math.floor(bounty_score)
if prev then
for _, player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name()
if bountied_player ~= name then
local _, prev_color = ctf_colors.get_color(prev, ctf.player(prev))
minetest.chat_send_player(player:get_player_name(),
minetest.colorize("#fff326", "Player ") ..
minetest.colorize(prev_color:gsub("0x", "#"), prev) ..
minetest.colorize("#fff326", " no longer has a bounty on their head!"))
end
end
end
minetest.after(0.1, announce_all)
end
@ -67,15 +77,11 @@ local function bounty_find_new_target()
end
minetest.after(math.random(500, 1000), bounty_find_new_target)
minetest.register_on_leaveplayer(function(player)
if bountied_player == player:get_player_name() then
bountied_player = nil
end
end)
minetest.register_on_joinplayer(function(player)
if bountied_player then
announce(player:get_player_name())
local name = player:get_player_name()
if bountied_player and
bountied_player ~= name then
announce(name)
end
end)