Skip to content

Commit

Permalink
Merge pull request #127 from KeepItLokiTho/main
Browse files Browse the repository at this point in the history
Fix apartments.starting related bug
  • Loading branch information
GhzGarage authored Jul 25, 2024
2 parents abcd2e0 + 76a7ecd commit 3dcabfd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 9 additions & 1 deletion client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ RegisterNetEvent('apartments:client:setupSpawnUI', function(cData)
else
TriggerEvent('qb-spawn:client:setupSpawns', cData, false, nil)
TriggerEvent('qb-spawn:client:openUI', true)
TriggerEvent('apartments:client:SetHomeBlip', nil)
end
end
end, cData.citizenid)
Expand Down Expand Up @@ -659,7 +660,14 @@ end)
RegisterNetEvent('apartments:client:UpdateApartment', function()
local apartmentType = ClosestHouse
local apartmentLabel = Apartments.Locations[ClosestHouse].label
TriggerServerEvent('apartments:server:UpdateApartment', apartmentType, apartmentLabel)
QBCore.Functions.TriggerCallback('apartments:GetOwnedApartment', function(result)
if result == nil then
TriggerServerEvent("apartments:server:CreateApartment", apartmentType, apartmentLabel, false)
else
TriggerServerEvent('apartments:server:UpdateApartment', apartmentType, apartmentLabel)
end
end)

IsOwned = true

DeleteApartmentsEntranceTargets()
Expand Down
6 changes: 4 additions & 2 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ RegisterNetEvent('apartments:server:openStash', function(CurrentApartment)
exports['qb-inventory']:OpenInventory(src, CurrentApartment)
end)

RegisterNetEvent('apartments:server:CreateApartment', function(type, label)
RegisterNetEvent('apartments:server:CreateApartment', function(type, label, firstSpawn)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local num = CreateApartmentId(type)
Expand All @@ -76,7 +76,9 @@ RegisterNetEvent('apartments:server:CreateApartment', function(type, label)
Player.PlayerData.citizenid
})
TriggerClientEvent('QBCore:Notify', src, Lang:t('success.receive_apart') .. ' (' .. label .. ')')
TriggerClientEvent('apartments:client:SpawnInApartment', src, apartmentId, type)
if firstSpawn then
TriggerClientEvent('apartments:client:SpawnInApartment', src, apartmentId, type)
end
TriggerClientEvent('apartments:client:SetHomeBlip', src, type)
end)

Expand Down

0 comments on commit 3dcabfd

Please sign in to comment.