From a3279ea5c81c6ea5dc3a0da765c1564aaa7fad82 Mon Sep 17 00:00:00 2001 From: Andyyy7666 <86536434+Andyyy7666@users.noreply.github.com> Date: Mon, 16 Oct 2023 00:28:36 +0200 Subject: [PATCH] feat(server): set character if not using multi character --- server/functions.lua | 4 ++++ server/main.lua | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/server/functions.lua b/server/functions.lua index fd0b19b..f2aafbd 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -88,6 +88,10 @@ function NDCore.getDiscordInfo(discordUserId) return data end +function NDCore.enableMultiCharacter(enable) + Config.multiCharacter = enable +end + for name, func in pairs(NDCore) do if type(func) == "function" then exports(name, func) diff --git a/server/main.lua b/server/main.lua index 7ebb546..e0c45f8 100644 --- a/server/main.lua +++ b/server/main.lua @@ -21,7 +21,8 @@ Config = { disableVehicleAirControl = GetConvarInt("core:disableVehicleAirControl", 1) == 1, useInventoryForKeys = GetConvarInt("core:useInventoryForKeys", 1) == 1, groups = json.decode(GetConvar("core:groups", "[]")), - admins = json.decode(GetConvar("core:admins", "[]")) + admins = json.decode(GetConvar("core:admins", "[]")), + multiCharacter = false } SetConvarServerInfo("Discord", Config.discordInvite) @@ -45,6 +46,23 @@ AddEventHandler("playerJoining", function(oldId) local src = source PlayersInfo[src] = tempPlayersInfo[oldId] tempPlayersInfo[oldId] = nil + + if Config.multiCharacter then return end + Wait(3000) + + local characters = NDCore.fetchAllCharacters(src) + local id = next(characters) + if id then + return NDCore.setActiveCharacter(src, id) + end + + local player = NDCore.newCharacter(src, { + firstname = GetPlayerName(src), + lastname = "", + dob = "", + gender = "" + }) + NDCore.setActiveCharacter(src, player.id) end) local function checkDiscordIdentifier(identifiers)