24 lines
No EOL
722 B
Lua
24 lines
No EOL
722 B
Lua
local ip_count = {}
|
|
local max_per_ip = 2
|
|
|
|
minetest.register_on_prejoinplayer(function(name, ip)
|
|
print(dump(ip_count))
|
|
if (ip_count[ip] or 0) >= max_per_ip then
|
|
return "ONLY MAX OF "..max_per_ip.." PLAYERS ALLOWED ON PER IP ADDRESS"
|
|
end
|
|
end)
|
|
|
|
minetest.register_on_joinplayer(function(ObjectRef, last_login)
|
|
local name = ObjectRef:get_player_name()
|
|
local ip = minetest.get_player_ip(name)
|
|
ip_count[ip] = (ip_count[ip] or 0) + 1
|
|
end)
|
|
|
|
minetest.register_on_leaveplayer(function(ObjectRef, timed_out)
|
|
local name = ObjectRef:get_player_name()
|
|
local ip = minetest.get_player_ip(name)
|
|
ip_count[ip] = ip_count[ip] - 1
|
|
if ip_count[ip] == 0 then
|
|
ip_count[ip] = nil
|
|
end
|
|
end) |