Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
tweak(cleint): prevent falling from garage shell when vehicle model i…
…s still loading
  • Loading branch information
renzuzu committed Aug 25, 2021
1 parent b95ec00 commit 79bed21
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions client/client.lua
Expand Up @@ -1330,6 +1330,10 @@ function GetVehicleProperties(vehicle)
if not Config.PlateSpace then
plate = string.gsub(tostring(GetVehicleNumberPlateText(vehicle)), '^%s*(.-)%s*$', '%1')
end
local modlivery = GetVehicleLivery(vehicle)
if modlivery == -1 then
modlivery = GetVehicleMod(vehicle, 48)
end
return {
model = GetEntityModel(vehicle),
plate = plate,
Expand Down Expand Up @@ -1411,7 +1415,7 @@ function GetVehicleProperties(vehicle)
modTrimB = GetVehicleMod(vehicle, 44),
modTank = GetVehicleMod(vehicle, 45),
modWindows = GetVehicleMod(vehicle, 46),
modLivery = GetVehicleLivery(vehicle)
modLivery = modlivery
}
else
return
Expand Down Expand Up @@ -2699,7 +2703,7 @@ function SpawnVehicle(vehicle, plate ,coord)
end

function SpawnVehicleLocal(model, props)
local ped = GetPlayerPed(-1)
local ped = PlayerPedId()

SetNuiFocus(true, true)
if LastVehicleFromGarage ~= nil then
Expand All @@ -2714,6 +2718,7 @@ function SpawnVehicleLocal(model, props)
local zaxis = actualShop.garage_z
local hash = tonumber(model)
local count = 0
FreezeEntityPosition(PlayerPedId(),true)
if not HasModelLoaded(hash) then
RequestModel(hash)
while not HasModelLoaded(hash) and count < 1111 do
Expand All @@ -2725,16 +2730,12 @@ function SpawnVehicleLocal(model, props)
end
end
LastVehicleFromGarage = CreateVehicle(hash, actualShop.garage_x,actualShop.garage_y,zaxis + 20, 42.0, 0, 1)
while not DoesEntityExist(LastVehicleFromGarage) do Wait(1) end
SetEntityHeading(LastVehicleFromGarage, 50.117)
FreezeEntityPosition(LastVehicleFromGarage, true)
SetEntityCollision(LastVehicleFromGarage,false)
SetVehicleProp(LastVehicleFromGarage, props)
currentcar = LastVehicleFromGarage
if currentcar ~= LastVehicleFromGarage then
DeleteEntity(LastVehicleFromGarage)
SetModelAsNoLongerNeeded(hash)
end
TaskWarpPedIntoVehicle(GetPlayerPed(-1), LastVehicleFromGarage, -1)
TaskWarpPedIntoVehicle(PlayerPedId(), LastVehicleFromGarage, -1)
InGarageShell('enter')
end
end
Expand Down Expand Up @@ -3193,6 +3194,7 @@ function CloseNui()
if neargarage then
neargarage = false
end
FreezeEntityPosition(PlayerPedId(),false)
SetNuiFocus(false, false)
InGarageShell('exit')
if inGarage then
Expand Down

0 comments on commit 79bed21

Please sign in to comment.