Difference between revisions of "Entity::destroy"

From RAGE Multiplayer Wiki
Jump to navigation Jump to search
 
Line 14: Line 14:
 
==Example==
 
==Example==
 
This example create vehicle, and destroy after few seconds.
 
This example create vehicle, and destroy after few seconds.
 +
{{SharedCode|
 
<pre>
 
<pre>
 
mp.events.addCommand('veh', (player) => {
 
mp.events.addCommand('veh', (player) => {
Line 24: Line 25:
 
});
 
});
 
</pre>
 
</pre>
 +
}}
 
}}
 
}}
  
 
[[Category:Entity API]]
 
[[Category:Entity API]]
 
[[Category:Shared Function]]
 
[[Category:Shared Function]]

Latest revision as of 12:30, 2 December 2019

Shared
Function

Js.png JavaScript


This function is used to destroy a created entity.

JavaScript Syntax
Jslogo.png


Syntax

entity.destroy();

Example

This example create vehicle, and destroy after few 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);
});