Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 37 additions & 25 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,40 +137,52 @@ RegisterNetEvent('qb-multicharacter:client:chooseChar', function()
end)

RegisterNetEvent('qb-multicharacter:client:spawnLastLocation', function(coords, cData)
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)

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
if GetResourceState('qb-apartement') == 'started' then
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)
end
local PlayerData = QBCore.Functions.GetPlayerData()
local insideMeta = PlayerData.metadata['inside']
DoScreenFadeOut(500)

TriggerServerEvent('QBCore:Server:OnPlayerLoaded')
TriggerEvent('QBCore:Client:OnPlayerLoaded')
Wait(2000)
DoScreenFadeIn(250)
end
end, cData.citizenid)
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

TriggerServerEvent('QBCore:Server:OnPlayerLoaded')
TriggerEvent('QBCore:Client:OnPlayerLoaded')
Wait(2000)
DoScreenFadeIn(250)
end
end, cData.citizenid)
else
local ped = PlayerPedId()
SetEntityCoords(ped, coords.x, coords.y, coords.z)
SetEntityHeading(ped, coords.w)
FreezeEntityPosition(ped, false)
SetEntityVisible(ped, true)
TriggerServerEvent('QBCore:Server:OnPlayerLoaded')
TriggerEvent('QBCore:Client:OnPlayerLoaded')
Wait(2000)
DoScreenFadeIn(250)
end
end)

-- NUI Callbacks

RegisterNUICallback('closeUI', function(_, cb)
RegisterNUICallback('closeUI', function(data, cb)
local cData = data.cData
DoScreenFadeOut(10)
TriggerServerEvent('qb-multicharacter:server:loadUserData', cData)
Expand Down