Vehicle::destroy: Difference between revisions
No edit summary |
No edit summary |
||
| Line 2: | Line 2: | ||
== Syntax == | == Syntax == | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
vehicle.destroy() | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== Example == | == Example == | ||
Revision as of 13:43, 5 January 2017
This functions destroys a vehicle.
Syntax
vehicle.destroy()
Example
This example destroys a random car from command.
mp.events.add('playerCommand', (player, cmd) => {
let arr = cmd.split(' ');
if (arr[0] == 'destroyrandomveh') {
let vehicles = mp.vehicles.toArray();
if (vehicles.length > 0) {
let randomValue = Math.floor(Math.random() * vehicles.length);
vehicles[randomValue].destroy();
} else {
player.outputChatBox('Vehicles does not exist!');
}
}
});