function core.string_to_privs(str, delim)
assert(type(str) == "string")
delim = delim or ','
- privs = {}
+ local privs = {}
for _, priv in pairs(string.split(str, delim)) do
privs[priv:trim()] = true
end
function core.privs_to_string(privs, delim)
assert(type(privs) == "table")
delim = delim or ','
- list = {}
+ local list = {}
for priv, bool in pairs(privs) do
if bool then
- table.insert(list, priv)
+ list[#list + 1] = priv
end
end
return table.concat(list, delim)
end
core.registered_auth_handler = handler
core.registered_auth_handler_modname = core.get_current_modname()
+ handler.mod_origin = core.registered_auth_handler_modname
end
function core.get_auth_handler()
record_login(player:get_player_name())
end)
+core.register_on_prejoinplayer(function(name, ip)
+ local auth = core.auth_table
+ if auth[name] ~= nil then
+ return
+ end
+
+ local name_lower = name:lower()
+ for k in pairs(auth) do
+ if k:lower() == name_lower then
+ return string.format("\nCannot create new player called '%s'. "..
+ "Another account called '%s' is already registered. "..
+ "Please check the spelling if it's your account "..
+ "or use a different nickname.", name, k)
+ end
+ end
+end)