Add userlimit skip if sufficient score
This commit is contained in:
parent
15653f7648
commit
d66cabe446
4 changed files with 30 additions and 11 deletions
|
@ -104,6 +104,20 @@ function chatplus.save()
|
||||||
end
|
end
|
||||||
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()
|
function chatplus.clean_players()
|
||||||
if not chatplus.players then
|
if not chatplus.players then
|
||||||
chatplus.players = {}
|
chatplus.players = {}
|
||||||
|
@ -112,17 +126,7 @@ function chatplus.clean_players()
|
||||||
|
|
||||||
minetest.log("[Chatplus] Cleaning player lists")
|
minetest.log("[Chatplus] Cleaning player lists")
|
||||||
for key,value in pairs(chatplus.players) do
|
for key,value in pairs(chatplus.players) do
|
||||||
if value.messages then
|
clean_player(key, value)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
chatplus.save()
|
chatplus.save()
|
||||||
end
|
end
|
||||||
|
@ -151,6 +155,7 @@ function chatplus.poke(name,player)
|
||||||
if player=="end" then
|
if player=="end" then
|
||||||
chatplus.players[name].enabled = false
|
chatplus.players[name].enabled = false
|
||||||
chatplus.loggedin[name] = nil
|
chatplus.loggedin[name] = nil
|
||||||
|
clean_player(name, chatplus.players[name])
|
||||||
else
|
else
|
||||||
if not chatplus.loggedin[name] then
|
if not chatplus.loggedin[name] then
|
||||||
chatplus.loggedin[name] = {}
|
chatplus.loggedin[name] = {}
|
||||||
|
|
|
@ -76,6 +76,10 @@ ctf.register_on_save(function()
|
||||||
return nil
|
return nil
|
||||||
end)
|
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`
|
-- Returns a tuple: `player_stats`, `match_player_stats`
|
||||||
function ctf_stats.player(name)
|
function ctf_stats.player(name)
|
||||||
local player_stats = ctf_stats.players[name]
|
local player_stats = ctf_stats.players[name]
|
||||||
|
|
2
mods/ctf_userlimit/depends.txt
Normal file
2
mods/ctf_userlimit/depends.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
ctf
|
||||||
|
ctf_stats
|
8
mods/ctf_userlimit/init.lua
Normal file
8
mods/ctf_userlimit/init.lua
Normal file
|
@ -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)
|
Loading…
Reference in a new issue