SetCargobobExcludeFromPickupEntity
DocsSetCargobobExcludeFromPickupEntity(cargobob, entity)Description
Prevents a specified entity from being detached from a Cargobob, even in the event of collisions.
Parameters
| Name | Type | Description |
|---|---|---|
cargobob | Vehicle | The Cargobob helicopter from which the entity is not to be detached |
entity | Entity | The entity to remain attached to the Cargobob. |
Quick Snippet: Get Vehiclecargobob
cargobobUse 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
voidThis native does not return a value.
Examples
Official
-- This example prevents a specific entity from being detached from a Cargobob, even in the event of collisions.
-- 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 cargobob exists. If not, terminate the script.
if not DoesEntityExist(cargobob) or GetHashKey("cargobob") ~= cargobobModel then
-- If the cargobob does not exist, end the execution of the code here.
return
end
local entityID = 15362 -- The entity you want to prevent from being detached 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
-- Prevent the entity from being detached from the Cargobob.
SetCargobobExcludeFromPickupEntity(cargobob, entityID)