diff --git a/server/functions.lua b/server/functions.lua index cb79941..8c585de 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -1,3 +1,10 @@ +function NDCore.getPlayerIdentifierByType(src, indentifierType) + if Config.sv_lan then + return ("%s:sv_lan"):format(indentifierType) + end + return GetPlayerIdentifierByType(src, indentifierType) +end + ---@param src number ---@return table function NDCore.getPlayer(src) diff --git a/server/main.lua b/server/main.lua index b4c575d..446cef8 100644 --- a/server/main.lua +++ b/server/main.lua @@ -26,7 +26,8 @@ Config = { adminDiscordRoles = json.decode(GetConvar("core:adminDiscordRoles", "[]")), groupRoles = json.decode(GetConvar("core:groupRoles", "[]")), multiCharacter = false, - compatibility = json.decode(GetConvar("core:compatibility", "[]")) + compatibility = json.decode(GetConvar("core:compatibility", "[]")), + sv_lan = GetConvar("sv_lan", "false") == "true", } SetConvarServerInfo("Discord", Config.discordInvite) @@ -43,6 +44,11 @@ local function getIdentifierList(src) list[identifierType] = identifier end end + + if Config.sv_lan then + list[Config.characterIdentifier] = NDCore.getPlayerIdentifierByType(src, Config.characterIdentifier) + end + return list end @@ -52,6 +58,10 @@ AddEventHandler("playerJoining", function(oldId) PlayersInfo[src] = tempPlayersInfo[oldTempId] tempPlayersInfo[oldTempId] = nil + if Config.sv_lan then + lib.addPrincipal(("player.%s"):format(src), "group.admin") + end + if Config.multiCharacter then return end Wait(3000) @@ -103,7 +113,7 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) if mainIdentifier and Config.discordBotToken ~= "false" and Config.discordGuildId ~= "false" then discordInfo = checkDiscordIdentifier(identifiers) - if not discordInfo and Config.discordMemeberRequired then + if not discordInfo and Config.discordMemeberRequired and not Config.sv_lan then deferrals.done(("Your discord was not found, join our discord here: %s."):format(Config.discordInvite)) Wait(0) end @@ -112,6 +122,17 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) deferrals.update("Connecting...") Wait(0) + if Config.sv_lan then + tempPlayersInfo[tempSrc] = { + identifiers = { + [Config.characterIdentifier] = "sv_lan" + }, + discord = discordInfo + } + deferrals.done() + return + end + if mainIdentifier then tempPlayersInfo[tempSrc] = { identifiers = identifiers, diff --git a/server/player.lua b/server/player.lua index 862f8bb..47eab0d 100644 --- a/server/player.lua +++ b/server/player.lua @@ -426,7 +426,7 @@ end ---@param info table ---@return table function NDCore.newCharacter(src, info) - local identifier = GetPlayerIdentifierByType(src, Config.characterIdentifier) + local identifier = NDCore.getPlayerIdentifierByType(src, Config.characterIdentifier) if not identifier then return end local charInfo = { @@ -468,7 +468,7 @@ end function NDCore.fetchCharacter(id, src) local result if src then - result = MySQL.query.await("SELECT * FROM nd_characters WHERE charid = ? and identifier = ?", {id, GetPlayerIdentifierByType(src, Config.characterIdentifier)}) + result = MySQL.query.await("SELECT * FROM nd_characters WHERE charid = ? and identifier = ?", {id, NDCore.getPlayerIdentifierByType(src, Config.characterIdentifier)}) else result = MySQL.query.await("SELECT * FROM nd_characters WHERE charid = ?", {id}) end @@ -497,7 +497,7 @@ end ---@return table function NDCore.fetchAllCharacters(src) local characters = {} - local result = MySQL.query.await("SELECT * FROM nd_characters WHERE identifier = ?", {GetPlayerIdentifierByType(src, Config.characterIdentifier)}) + local result = MySQL.query.await("SELECT * FROM nd_characters WHERE identifier = ?", {NDCore.getPlayerIdentifierByType(src, Config.characterIdentifier)}) for i=1, #result do local info = result[i]