Native referenceFiveM

ATTACH_VEHICLE_TO_CARGOBOB

0x4127F1D84E347769 VEHICLE
FUNCTION SIGNATURE
void ATTACH_VEHICLE_TO_CARGOBOB(Vehicle cargobob, Vehicle vehicle, int vehicleBoneIndex, float x, float y, float z);
Property Value
Native Name ATTACH_VEHICLE_TO_CARGOBOB
Hash 0x4127F1D84E347769
Return Type void
Parameters cargobob (Vehicle), vehicle (Vehicle), vehicleBoneIndex (int), x (float), y (float), z (float)

Parameters

  • cargobob (Vehicle) — The cargobob
  • vehicle (Vehicle) — The vehicle that will be attached
  • vehicleBoneIndex (int) — A Vehicle bone the hook/magnet should attach to or -1 for none/default GET_ENTITY_BONE_INDEX_BY_NAME
  • x (float) — x hook/magnet Offset
  • y (float) — y hook/magnet Offset
  • z (float) — z hook/magnet Offset

Examples

function RequestVehicleModel(modelHash)
    if not IsModelInCdimage(modelHash) then return end
    RequestModel(modelHash)
    while not HasModelLoaded(modelHash) do 
      Wait(0)
    end
end

RegisterCommand('spawnCargobob', function(source, args)
    local cargobobHash = `cargobob` 
    local carHash = `adder` 
    local myPed = PlayerPedId()

    local spawnCoords = GetEntityCoords(myPed)

    RequestVehicleModel(cargobobHash)
    local cargobob = CreateVehicle(cargobobHash, spawnCoords+vec3(0.0,0.0, 10.0), GetEntityHeading(myPed), true, false) -- Spawns a cargobob above players location
    SetHeliBladesSpeed(cargobob, 1.0) -- sets the helicoper blades to max spin speed
    SetPedIntoVehicle(myPed, cargobob, -1) -- sets the player into the cargobob
    SetModelAsNoLongerNeeded(cargobobHash) -- removes model from game memory as we no longer need it
    CreatePickUpRopeForCargobob(cargobob, 1) -- 0 = hook, 1 = Magnet Enable rope from cargobob

    RequestVehicleModel(carHash)
    local vehicle = CreateVehicle(carHash, spawnCoords, GetEntityHeading(myPed), true, false) -- Spawns a vehicle for the cargobob to pickup
    SetModelAsNoLongerNeeded(carHash)
    Wait(1000)
    AttachVehicleToCargobob(cargobob, vehicle, GetEntityBoneIndexByName(vehicle, 'bodyshell'), 0.0, 0.0, 0.0) --Attach the vehicle to the magnet or hook
end)
Back to VEHICLE