CreateAutoMoblie native does not sync landing gears

Hey, I noticed a bug with the CreateAutoMobile native; planes created by this native does not sync landing gears status and animations.

The script I used:

local CreateAutoMobile = function(model, x, y, z, heading) return Citizen.InvokeNative(`CREATE_AUTOMOBILE`, model, x, y, z, heading) end

local plane = `cuban800`
RegisterCommand("automobile", function(source, args, raw)
	local ped = GetPlayerPed(source)
	local pos = GetEntityCoords(ped)
	CreateAutoMobile(plane, pos.x, pos.y, pos.z, 0.0)
end)
RegisterCommand("vehicle", function(source, args, raw)
	local ped = GetPlayerPed(source)
	local pos = GetEntityCoords(ped)
	CreateVehicle(plane, pos.x, pos.y, pos.z, 0.0, true, true, true)
end)

Steps to see the problem:

  1. Join the server with a friend.
  2. Spawn a vehicle using automobile command which using CreateAutoMobile native.
  3. Fly with your friend and fold the plane wheels (Default G)
  4. Now your friend won’t see and changes to the landing gears status or animation.

Now, if you do the literally same thing with CreateVehicle, it will sync:

  1. Join the server with a friend.
  2. Spawn a vehicle using vehicle command which using CreateVehicle native.
  3. Fly with your friend and fold the plane wheels (Default G)
  4. Now your friend should see that the landing gears animation play just fine.

DEMO VIDEO:

CREATE_AUTOMOBILE is only intended to be used with automobiles, not planes.

So spawning planes is a bug? Or the landing gears stuck is an intended behavior?

This native will always create a CNetObjAutomobile, which inherently can not sync data exclusive to other vehicle
types like planes or helicopters.

This is also why the native isn’t documented or even added by name: it’s not finished and if it could know what the vehicle type is, it’d just replace CREATE_VEHICLE, this unfinished version was added for testing purposes mostly. Making specific functions for each type was seen as undesirable at the time, but the server also doesn’t have any means of mapping a model hash to a vehicle type, see also Vehicle metadata indexing on server · Issue #840 · citizenfx/fivem · GitHub.

The only ‘issue’ here is that this took way too long to get correctly implemented mainly as parsing stuff server-side is difficult and there’s usually more important issues to fix + people don’t ask about this often enough.

2 Likes