Entity::destroy: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
m (Adjusting some grammatical mistakes.)
Line 13: Line 13:


==Example==
==Example==
This example create vehicle, and destroy after few seconds.
This example creates a vehicle, and destroys after waiting 5 seconds.
{{SharedCode|
{{SharedCode|
<pre>
<pre>

Revision as of 14:58, 28 August 2020

Shared
Function

 JavaScript


This function is used to destroy a created entity.

JavaScript Syntax


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