Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix character spawning issue when Config.SkipSelection is true #245

Closed
wants to merge 2 commits into from
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
52 changes: 29 additions & 23 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,34 +137,40 @@ 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)
local PlayerData = QBCore.Functions.GetPlayerData()
local insideMeta = PlayerData.metadata["inside"]
DoScreenFadeOut(500)

local isInsideProperty = function()
return insideMeta.house or (insideMeta.apartment.apartmentType and 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)
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
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 isInsideProperty() then
handleLocation()
end

TriggerServerEvent('QBCore:Server:OnPlayerLoaded')
TriggerEvent('QBCore:Client:OnPlayerLoaded')
Wait(2000)
DoScreenFadeIn(250)
end, cData.citizenid)
end)

Expand Down
Loading