Entity::destroy

From RAGE Multiplayer Wiki
Revision as of 14:58, 28 August 2020 by GettyPlays (talk | contribs) (Adjusting some grammatical mistakes.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Shared
Function

Js.png JavaScript


This function is used to destroy a created entity.

JavaScript Syntax
Jslogo.png


Syntax

entity.destroy();

Example

This example creates a vehicle, and destroys after waiting 5 seconds.

Shared
mp.events.addCommand('veh', (player) => {
    let vehicle = mp.vehicles.new(mp.joaat(`zentorno`), player.position); //Create a Vehicle
    setTimeout(()=>{ //Create a Timer
        if(vehicle){
            vehicle.destroy(); //Destroy the Vehicle
        }
    },5000);
});