Skip to content

Commit

Permalink
Merge pull request #901 from gtasnail/patch-1
Browse files Browse the repository at this point in the history
Update AttachVehicleToCargobob.md
  • Loading branch information
thorium-cfx authored Oct 30, 2023
2 parents 13e14d3 + 1fd25c4 commit 47b74b7
Showing 1 changed file with 39 additions and 10 deletions.
49 changes: 39 additions & 10 deletions VEHICLE/AttachVehicleToCargobob.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,47 @@ ns: VEHICLE

```c
// 0x4127F1D84E347769 0x607DC9D5
void ATTACH_VEHICLE_TO_CARGOBOB(Vehicle vehicle, Vehicle cargobob, int p2, float x, float y, float z);
```
```
p2 is unknown and is always -1 in the script natives.
void ATTACH_VEHICLE_TO_CARGOBOB(Vehicle cargobob, Vehicle vehicle, int vehicleBoneIndex, float x, float y, float z);
```
## Parameters
* **vehicle**: The vehicle which should be attached
* **cargobob**: The cargobob
* **p2**:
* **x**:
* **y**:
* **z**:
* **vehicle**: The vehicle that will be attached
* **vehicleBoneIndex**: A Vehicle bone the hook/magnet should attach to or -1 for none/default [GET_ENTITY_BONE_INDEX_BY_NAME](#_0xFB71170B7E76ACBA)
* **x**: x hook/magnet Offset
* **y**: y hook/magnet Offset
* **z**: z hook/magnet Offset
## Examples
```lua
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)
```

0 comments on commit 47b74b7

Please sign in to comment.