Entity::destroy: Difference between revisions

From RAGE Multiplayer Wiki
m (category)
No edit summary
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

 JavaScript


This function is used to destroy a created entity.

JavaScript Syntax


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