DeleteEntity
Docslocal entity = DeleteEntity()Description
Delete the specified entity, and invalidate the passed handle (i.e., the in/out argument).
You might want to check if the entity exists before with [DOES_ENTITY_EXIST](#\_0x7239B21A38F536BA).
Parameters
| Name | Type | Description |
|---|---|---|
entity | Entity* | The entity to delete. |
Quick 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
endReturns
voidExamples
Official
-- Retrieve the vehicle the player is currently in.
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
-- Check if the vehicle exists in the game world.
if not DoesEntityExist(vehicle) then
-- If the vehicle does not exist, end the execution of the code here.
return
end
-- If the vehicle does exist, delete the vehicle entity from the game world.
DeleteEntity(vehicle)