Difference between revisions of "Entity::destroy"

From RAGE Multiplayer Wiki
Jump to navigation Jump to search
m (category)
Line 1: Line 1:
 +
__TOC__
 +
 +
{{SharedFunctionJS}}
 +
 
This function is used to destroy a created entity.
 
This function is used to destroy a created entity.
 +
 +
{{JSContainer|
  
 
==Syntax==
 
==Syntax==
<syntaxhighlight lang="typescript">
+
<pre>
 
entity.destroy();
 
entity.destroy();
</syntaxhighlight>  
+
</pre>  
  
 
==Example==
 
==Example==
 
This example create vehicle, and destroy after few seconds.
 
This example create vehicle, and destroy after few seconds.
<div class="header" style="background-color: #00baad; color: #FFFFFF; border: 2px solid #00baad;">
 
<div style="margin: 10px 10px 10px 10px;"><b>Shared</b></div>
 
 
<pre>
 
<pre>
 
mp.events.addCommand('veh', (player) => {
 
mp.events.addCommand('veh', (player) => {
Line 20: Line 24:
 
});
 
});
 
</pre>
 
</pre>
</div>
+
}}
  
 
[[Category:Entity API]]
 
[[Category:Entity API]]
 
[[Category:Shared Function]]
 
[[Category:Shared Function]]

Revision as of 12:24, 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.

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