From 6bfcae834b83a7f987c6b22e323705ace6478945 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Tue, 14 Jul 2015 13:57:53 +0100 Subject: [PATCH] Make player return flag if they leave the game --- mods/capturetheflag/ctf_flag/flag_func.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mods/capturetheflag/ctf_flag/flag_func.lua b/mods/capturetheflag/ctf_flag/flag_func.lua index 575811e..7e34518 100644 --- a/mods/capturetheflag/ctf_flag/flag_func.lua +++ b/mods/capturetheflag/ctf_flag/flag_func.lua @@ -70,9 +70,7 @@ local function do_capture(attname, flag, returned) ctf.needs_save = true end -minetest.register_on_dieplayer(function(player) - local name = player:get_player_name() - +function ctf_flag.player_drop_flag(name) for i = 1, #ctf_flag.claimed do local flag = ctf_flag.claimed[i] if flag.claimed.player == name then @@ -89,7 +87,12 @@ minetest.register_on_dieplayer(function(player) end end -end) +end +local function player_drop_flag(player) + return ctf_flag.player_drop_flag(player:get_player_name()) +end +minetest.register_on_dieplayer(player_drop_flag) +minetest.register_on_leaveplayer(player_drop_flag) ctf_flag = {