diff --git a/mods/chatplus/api.lua b/mods/chatplus/api.lua index 796d66e..9461e4e 100644 --- a/mods/chatplus/api.lua +++ b/mods/chatplus/api.lua @@ -104,6 +104,20 @@ function chatplus.save() end end +local function clean_player(name, value) + if value.messages then + value.inbox = value.messages + value.messages = nil + end + + if ( + (not value.inbox or #value.inbox==0) and + (not value.ignore or #value.ignore==0) + ) then + chatplus.players[name] = nil + end +end + function chatplus.clean_players() if not chatplus.players then chatplus.players = {} @@ -112,17 +126,7 @@ function chatplus.clean_players() minetest.log("[Chatplus] Cleaning player lists") for key,value in pairs(chatplus.players) do - if value.messages then - value.inbox = value.messages - value.messages = nil - end - - if ( - (not value.inbox or #value.inbox==0) and - (not value.ignore or #value.ignore==0) - ) then - chatplus.players[key] = nil - end + clean_player(key, value) end chatplus.save() end @@ -151,6 +155,7 @@ function chatplus.poke(name,player) if player=="end" then chatplus.players[name].enabled = false chatplus.loggedin[name] = nil + clean_player(name, chatplus.players[name]) else if not chatplus.loggedin[name] then chatplus.loggedin[name] = {} diff --git a/mods/ctf_stats/init.lua b/mods/ctf_stats/init.lua index a5a84bf..023b10d 100644 --- a/mods/ctf_stats/init.lua +++ b/mods/ctf_stats/init.lua @@ -76,6 +76,10 @@ ctf.register_on_save(function() return nil end) +function ctf_stats.player_or_nil(name) + return ctf_stats.players[name], ctf_stats.current.red[name] or ctf_stats.current.blue[name] +end + -- Returns a tuple: `player_stats`, `match_player_stats` function ctf_stats.player(name) local player_stats = ctf_stats.players[name] diff --git a/mods/ctf_userlimit/depends.txt b/mods/ctf_userlimit/depends.txt new file mode 100644 index 0000000..bbf75ef --- /dev/null +++ b/mods/ctf_userlimit/depends.txt @@ -0,0 +1,2 @@ +ctf +ctf_stats diff --git a/mods/ctf_userlimit/init.lua b/mods/ctf_userlimit/init.lua new file mode 100644 index 0000000..61e8150 --- /dev/null +++ b/mods/ctf_userlimit/init.lua @@ -0,0 +1,8 @@ +minetest.register_can_bypass_userlimit(function(name, ip) + local pstat, discard = ctf_stats.player_or_nil(name) + local actual_max_users = tonumber(minetest.settings:get("max_users")) + + tonumber(minetest.settings:get("max_extra_users") or "10") + local req_score = tonumber(minetest.settings:get("userlimit_bypass_required_score") or "10000") + + return pstat and pstat.score > req_score and #minetest.get_connected_players() < actual_max_users +end)