Skip to content

Commit

Permalink
add last_ip field in plaer meta to track last successful login
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Dec 30, 2024
1 parent 8ff655a commit 7269463
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions player_stats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 7269463

Please sign in to comment.