What happens:
- The
spawnLastLocationevent depends on this callback:
QBCore.Functions.TriggerCallback('apartments:GetOwnedApartment', function(result)
if result then
-- all the spawn logic is inside here
end
end)
-
If the player doesn't have an apartment,
resultwill benil, and the spawn logic won’t run. -
Since everything depends on
if result then, the player gets stuck on a black screen (or sees the sky), and the character is never fully loaded.
Cause:
Even if the player doesn’t have an apartment, the server still sends valid coords.
However, the current code unnecessarily blocks the spawn, requiring an apartment when it’s not actually needed.
Solution:
Remove the dependency on the apartment callback and use the received coordinates directly.
Fixed code:
RegisterNetEvent('qb-multicharacter:client:spawnLastLocation', function(coords, cData)
local ped = PlayerPedId()
SetEntityCoords(ped, coords.x, coords.y, coords.z)
SetEntityHeading(ped, coords.w or 0.0)
FreezeEntityPosition(ped, false)
SetEntityVisible(ped, true)
DoScreenFadeOut(500)
local PlayerData = QBCore.Functions.GetPlayerData()
local insideMeta = PlayerData.metadata['inside'] or {}
if insideMeta.house then
TriggerEvent('qb-houses:client:LastLocationHouse', insideMeta.house)
elseif insideMeta.apartment and insideMeta.apartment.apartmentType and insideMeta.apartment.apartmentId then
TriggerEvent('qb-apartments:client:LastLocationHouse', insideMeta.apartment.apartmentType, insideMeta.apartment.apartmentId)
end
TriggerServerEvent('QBCore:Server:OnPlayerLoaded')
TriggerEvent('QBCore:Client:OnPlayerLoaded')
Wait(2000)
DoScreenFadeIn(250)
end)
Note: Since this is an unofficial fix, I don’t recommend replacing the original block directly.
Instead, you can comment out the original code and paste this version below for safety.