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

Added check for spawned vehicles not on all wheels then it rotates #1185

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion [core]/es_extended/client/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,11 @@ function ESX.Game.SpawnVehicle(vehicleModel, coords, heading, cb, networked)
while not HasCollisionLoadedAroundEntity(vehicle) do
Wait(0)
end

if not IsVehicleOnAllWheels(vehicle) then
local carCoords = GetEntityRotation(vehicle, 2)
Wait(500)
SetEntityRotation(vehicle, carCoords[1], 0, carCoords[3], 2, true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this 1-3 index all time?

Copy link
Author

@Manta95 Manta95 Aug 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, tried with all kind of vehicles (mostly addons trailers, boats and planes) and it works well, cause it put the rotation from side of the chassis in the longitudinal axis

You can try with this trailer who spawn upside-down https://www.gta5-mods.com/vehicles/brute-camp-trailer-addon

end
if cb then
cb(vehicle)
end
Expand Down
5 changes: 5 additions & 0 deletions [core]/es_extended/server/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ ESX.RegisterCommand('car', 'admin', function(xPlayer, args, showError)
if GetVehiclePedIsIn(playerPed, false) ~= vehicle then
showError('[^1ERROR^7] The player could not be seated in the vehicle')
end
if not IsVehicleOnAllWheels(vehicle) then
local carCoords = GetEntityRotation(vehicle, 2)
Wait(500)
SetEntityRotation(vehicle, carCoords[1], 0, carCoords[3], 2, true)
end
end
end)
end, false, {
Expand Down