mirror of
https://github.com/SmallJoker/names_per_ip.git
synced 2025-01-05 15:10:20 +01:00
parent
16e1fa84c2
commit
da6110de50
16
init.lua
16
init.lua
@ -59,24 +59,23 @@ minetest.register_chatcommand("ipnames", {
|
|||||||
minetest.register_on_prejoinplayer(function(name, ip)
|
minetest.register_on_prejoinplayer(function(name, ip)
|
||||||
-- Only stop new accounts
|
-- Only stop new accounts
|
||||||
ipnames.tmp_data[name] = ip
|
ipnames.tmp_data[name] = ip
|
||||||
|
|
||||||
if ipnames.data[name] then
|
if ipnames.data[name] then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local names = {} -- faster than string concat
|
local names = {} -- faster than string concat
|
||||||
local limit_ext = false
|
local count_bonus = nil
|
||||||
for k, v in pairs(ipnames.data) do
|
for k, v in pairs(ipnames.data) do
|
||||||
if v[1] == ip then
|
if v[1] == ip then
|
||||||
if not limit_ext and ipnames.whitelist[k] then
|
if not count_bonus and ipnames.whitelist[k] then
|
||||||
count = count - ipnames.extended_limit
|
count_bonus = ipnames.extended_limit
|
||||||
limit_ext = true
|
|
||||||
end
|
end
|
||||||
names[#names + 1] = k
|
names[#names + 1] = k
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Return error message if too many accounts have been created
|
-- Return error message if too many accounts have been created
|
||||||
if #names > ipnames.name_per_ip_limit then
|
if #names > ipnames.name_per_ip_limit + (count_bonus or 0) then
|
||||||
ipnames.tmp_data[name] = nil
|
ipnames.tmp_data[name] = nil
|
||||||
return "\nYou exceeded the limit of accounts.\n" ..
|
return "\nYou exceeded the limit of accounts.\n" ..
|
||||||
"You already own the following accounts:\n" .. table.concat(names, ", ")
|
"You already own the following accounts:\n" .. table.concat(names, ", ")
|
||||||
@ -92,6 +91,11 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
ipnames.changes = true
|
ipnames.changes = true
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- Clean up garbage
|
||||||
|
minetest.register_on_leaveplayer(function(player)
|
||||||
|
ipnames.tmp_data[player:get_player_name()] = nil
|
||||||
|
end)
|
||||||
|
|
||||||
minetest.register_globalstep(function(t)
|
minetest.register_globalstep(function(t)
|
||||||
ipnames.save_time = ipnames.save_time + t
|
ipnames.save_time = ipnames.save_time + t
|
||||||
if ipnames.save_time < ipnames.save_interval then
|
if ipnames.save_time < ipnames.save_interval then
|
||||||
|
Loading…
Reference in New Issue
Block a user