DetachEntityFromCargobob
Docslocal retval = DetachEntityFromCargobob(vehicle, entity)Description
Detaches the specified entity currently being carried by a Cargobob.
Parameters
| Name | Type | Description |
|---|---|---|
vehicle | Vehicle | The Cargobob helicopter. |
entity | Entity | The entity to be detached. |
Quick Snippet: Get Vehiclevehicle
vehicleUse this to get the current vehicle handle for this native.
-- Get the vehicle the player is currently in
local ped = PlayerPedId()
local vehicle = GetVehiclePedIsIn(ped, false)
if vehicle ~= 0 then
print("Vehicle handle: " .. vehicle)
print("Model: " .. GetEntityModel(vehicle))
else
print("Player is not in a vehicle")
endQuick Snippet: Get Entityentity
entityUse this to obtain an entity handle from the player's aim or crosshair.
-- Get the entity the player is aiming at
local ped = PlayerPedId()
local hit, entity = GetEntityPlayerIsFreeAimingAt(PlayerId())
if hit and entity ~= 0 then
print("Entity: " .. entity)
print("Model: " .. GetEntityModel(entity))
print("Type: " .. GetEntityType(entity)) -- 1=Ped, 2=Vehicle, 3=Object
endVehicle Models

adder
alpha
blade
ardent
asea
cogcabrio
baller
blistaReturns
AnyReturn type varies depending on context.
Examples
Official
-- This example detaches a specific entity from a Cargobob.
-- Retrieve the player ped.
local playerPed = PlayerPedId()
-- Retrieve the player's vehicle (cargobob).
local cargobob = GetVehiclePedIsIn(playerPed, false)
-- Retrieve the model hash of the cargobob.
local cargobobModel = GetEntityModel(cargobob)
-- Check if the vehicle exists and if it's a Cargobob. If not, terminate the script.
if not DoesEntityExist(cargobob) or cargobobModel ~= GetHashKey("cargobob") then
return
end
local entityID = 15362 -- The entity you want to detach from the Cargobob (this is a random entity ID).
-- Check if the entity exists; if not, terminate the script.
if not DoesEntityExist(yourEntity) then
return
end
-- Detach the entity from the Cargobob.
DetachEntityFromCargobob(cargobob, entityID)