-- 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)