From 726946374eff818e8fad90d75811809bf800cac4 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Mon, 30 Dec 2024 19:17:41 +0100 Subject: [PATCH] add `last_ip` field in plaer meta to track last successful login --- player_stats.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/player_stats.lua b/player_stats.lua index 0cc0315..faf4112 100644 --- a/player_stats.lua +++ b/player_stats.lua @@ -44,4 +44,22 @@ end) minetest.register_on_craft(function(itemstack, player) increase_stat(player, "crafted", itemstack:get_count()) +end) + +-- last-ip tracking +local last_ips = {} + +minetest.register_on_authplayer(function(name, ip, is_success) + if is_success then + -- store ip temporarily + last_ips[name] = ip + end +end) + +minetest.register_on_joinplayer(function(player) + -- store ip in player meta permanently + local playername = player:get_player_name() + local meta = player:get_meta() + meta:set_string("last_ip", last_ips[playername]) + last_ips[playername] = nil end) \ No newline at end of file