From 70f98c39a9f02adbfc79bc914e3fefde14956b8b Mon Sep 17 00:00:00 2001 From: SuperDaniel <56658457+TransitNode@users.noreply.github.com> Date: Wed, 29 May 2024 01:02:23 +0200 Subject: [PATCH 1/2] /logout bug fix Fix character spawning issue when Config.SkipSelection is true --- client/main.lua | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/client/main.lua b/client/main.lua index 1708c80..e33f789 100644 --- a/client/main.lua +++ b/client/main.lua @@ -137,34 +137,43 @@ RegisterNetEvent('qb-multicharacter:client:chooseChar', function() end) RegisterNetEvent('qb-multicharacter:client:spawnLastLocation', function(coords, cData) + local ped = PlayerPedId() + SetEntityCoords(ped, coords.x, coords.y, coords.z) + SetEntityHeading(ped, coords.w) + FreezeEntityPosition(ped, false) + SetEntityVisible(ped, true) + QBCore.Functions.TriggerCallback('apartments:GetOwnedApartment', function(result) - if result then - TriggerEvent("apartments:client:SetHomeBlip", result.type) - local ped = PlayerPedId() - SetEntityCoords(ped, coords.x, coords.y, coords.z) - SetEntityHeading(ped, coords.w) - FreezeEntityPosition(ped, false) - SetEntityVisible(ped, true) - local PlayerData = QBCore.Functions.GetPlayerData() - local insideMeta = PlayerData.metadata["inside"] - DoScreenFadeOut(500) + local PlayerData = QBCore.Functions.GetPlayerData() + local insideMeta = PlayerData.metadata["inside"] + + DoScreenFadeOut(500) + local function isInsideProperty() + return insideMeta.house or (insideMeta.apartment.apartmentType and insideMeta.apartment.apartmentId) + end + + local function handleLocation() if insideMeta.house then TriggerEvent('qb-houses:client:LastLocationHouse', insideMeta.house) elseif insideMeta.apartment.apartmentType and insideMeta.apartment.apartmentId then TriggerEvent('qb-apartments:client:LastLocationHouse', insideMeta.apartment.apartmentType, insideMeta.apartment.apartmentId) - else - SetEntityCoords(ped, coords.x, coords.y, coords.z) - SetEntityHeading(ped, coords.w) - FreezeEntityPosition(ped, false) - SetEntityVisible(ped, true) end + end - TriggerServerEvent('QBCore:Server:OnPlayerLoaded') - TriggerEvent('QBCore:Client:OnPlayerLoaded') - Wait(2000) - DoScreenFadeIn(250) + if result then + TriggerEvent("apartments:client:SetHomeBlip", result.type) + end + + if isInsideProperty() then + handleLocation() end + + TriggerServerEvent('QBCore:Server:OnPlayerLoaded') + TriggerEvent('QBCore:Client:OnPlayerLoaded') + + Wait(2000) + DoScreenFadeIn(250) end, cData.citizenid) end) From 0d69556310467bafa7a8b9aa256064a8108ed62a Mon Sep 17 00:00:00 2001 From: SuperDaniel <56658457+TransitNode@users.noreply.github.com> Date: Sun, 2 Jun 2024 18:49:21 +0200 Subject: [PATCH 2/2] Fix linting error and adjust code to fit codebase. Removed code that was causing the linting error and adjusted the indention and code to fit the existing codebase. --- client/main.lua | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/client/main.lua b/client/main.lua index e33f789..b2da6f8 100644 --- a/client/main.lua +++ b/client/main.lua @@ -142,25 +142,23 @@ RegisterNetEvent('qb-multicharacter:client:spawnLastLocation', function(coords, SetEntityHeading(ped, coords.w) FreezeEntityPosition(ped, false) SetEntityVisible(ped, true) + local PlayerData = QBCore.Functions.GetPlayerData() + local insideMeta = PlayerData.metadata["inside"] + DoScreenFadeOut(500) - QBCore.Functions.TriggerCallback('apartments:GetOwnedApartment', function(result) - local PlayerData = QBCore.Functions.GetPlayerData() - local insideMeta = PlayerData.metadata["inside"] - - DoScreenFadeOut(500) - - local function isInsideProperty() - return insideMeta.house or (insideMeta.apartment.apartmentType and insideMeta.apartment.apartmentId) - end + local isInsideProperty = function() + return insideMeta.house or (insideMeta.apartment.apartmentType and insideMeta.apartment.apartmentId) + end - local function handleLocation() - if insideMeta.house then - TriggerEvent('qb-houses:client:LastLocationHouse', insideMeta.house) - elseif insideMeta.apartment.apartmentType and insideMeta.apartment.apartmentId then - TriggerEvent('qb-apartments:client:LastLocationHouse', insideMeta.apartment.apartmentType, insideMeta.apartment.apartmentId) - end + local handleLocation = function() + if insideMeta.house then + TriggerEvent('qb-houses:client:LastLocationHouse', insideMeta.house) + elseif insideMeta.apartment.apartmentType and insideMeta.apartment.apartmentId then + TriggerEvent('qb-apartments:client:LastLocationHouse', insideMeta.apartment.apartmentType, insideMeta.apartment.apartmentId) end + end + QBCore.Functions.TriggerCallback('apartments:GetOwnedApartment', function(result) if result then TriggerEvent("apartments:client:SetHomeBlip", result.type) end @@ -171,7 +169,6 @@ RegisterNetEvent('qb-multicharacter:client:spawnLastLocation', function(coords, TriggerServerEvent('QBCore:Server:OnPlayerLoaded') TriggerEvent('QBCore:Client:OnPlayerLoaded') - Wait(2000) DoScreenFadeIn(250) end, cData.citizenid)