diff --git a/mods/ctf/ctf_bounties/init.lua b/mods/ctf/ctf_bounties/init.lua index 604bf0f..88cb091 100644 --- a/mods/ctf/ctf_bounties/init.lua +++ b/mods/ctf/ctf_bounties/init.lua @@ -91,6 +91,14 @@ ctf.register_on_killedplayer(function(victim, killer) match.score = match.score + bounty_score main.bounty_kills = main.bounty_kills + 1 match.bounty_kills = match.bounty_kills + 1 + + ctf_stats.request_save() + + hud_score.new(killer, { + name = "ctf_bounty:prize", + color = 0x4444FF, + value = bounty_score + }) end bountied_player = nil @@ -102,11 +110,6 @@ ctf.register_on_killedplayer(function(victim, killer) minetest.colorize("#fff326", " and received " .. bounty_score .. " points!") minetest.log("action", minetest.strip_colors(msg)) minetest.chat_send_all(msg) - hud_score.new(killer, { - name = "ctf_bounty:prize", - color = 0x4444FF, - value = bounty_score - }) end) minetest.register_privilege("bounty_admin") diff --git a/mods/ctf/ctf_classes/medic.lua b/mods/ctf/ctf_classes/medic.lua index b34aec8..b5f85b3 100644 --- a/mods/ctf/ctf_classes/medic.lua +++ b/mods/ctf/ctf_classes/medic.lua @@ -91,6 +91,8 @@ minetest.override_item("ctf_bandages:bandage", { color = "0x00FF00", value = reward }) + + ctf_stats.request_save() end end end diff --git a/mods/ctf/ctf_stats/chat.lua b/mods/ctf/ctf_stats/chat.lua index 28142d6..ae5a682 100644 --- a/mods/ctf/ctf_stats/chat.lua +++ b/mods/ctf/ctf_stats/chat.lua @@ -161,6 +161,7 @@ minetest.register_chatcommand("reset_rankings", { ctf_stats.players[reset_name] = nil ctf_stats.player(reset_name) + ctf_stats.request_save() if reset_name == name then minetest.log("action", name .. " reset their rankings") @@ -198,6 +199,8 @@ minetest.register_chatcommand("transfer_rankings", { ctf_stats.players[dest] = ctf_stats.players[src] ctf_stats.players[src] = nil + ctf_stats.request_save() + minetest.log("action", name .. " transferred stats of " .. src .. " to " .. dest) return true, "Stats of '" .. src .. "' have been transferred to '" .. dest .. "'." end diff --git a/mods/ctf/ctf_stats/init.lua b/mods/ctf/ctf_stats/init.lua index 9f45d92..19f0d8e 100644 --- a/mods/ctf/ctf_stats/init.lua +++ b/mods/ctf/ctf_stats/init.lua @@ -110,7 +110,10 @@ local function check_if_save_needed() end minetest.after(13, check_if_save_needed) - minetest.after(13, ctf_stats.save) +-- API function to allow other mods to request a save +-- TODO: This should be done automatically once a proper API is in place +function ctf_stats.request_save() + _needs_save = true end function ctf_stats.player_or_nil(name)