Entity::destroy

From RAGE Multiplayer Wiki

Shared
Function

 JavaScript


JavaScript Syntax

This method is used to destroy a created entity, see Entity::type for a list of entities you can use this method to.

Syntax

entity.destroy();

Example

Below you will find examples of this method being used in each entity

Shared


//Vehicle
const vehicle = mp.vehicles.at(0); //find vehicle with id 0.
if (vehicle && mp.vehicles.exists(vehicle)) vehicle.destroy(); //destroy the vehicle if it exists and its valid.


//Ped (NPC)
const ped = mp.peds.at(0); //find ped with id 0.
if (ped && mp.peds.exists(ped)) ped.destroy(); //destroy the ped if it exists and its valid.


//Colshape
const colshape = mp.colshapes.at(0); //find colshape with id 0
if (colshape && mp.colshapes.exists(colshape)) colshape.destroy(); //destroy the colshape if it exists and its valid.


//Textlabel
const label = mp.labels.at(0); //find label with id 0
if (label && mp.labels.exists(label)) label.destroy(); //destroy the label if it exists and its valid.


//Object
const object = mp.objects.at(0); //find object with id 0
if (object && mp.objects.exists(object)) object.destroy(); //destroy the object if it exists and its valid.

//Blip
const blip = mp.blips.at(0); //find blip with id 0
if (blip && mp.blips.exists(blip)) blip.destroy(); //destroy the blip if it exists and its valid.


//Marker
const marker = mp.markers.at(0); //find marker with id 0
if (marker && mp.markers.exists(marker)) marker.destroy(); //destroy the marker if it exists and its valid.


//Checkpoint
const checkpoint = mp.checkpoints.at(0); //find marker with id 0
if (checkpoint && mp.checkpoints.exists(checkpoint)) checkpoint.destroy(); //destroy the marker if it exists and its valid.