Vehicle::destroy: Difference between revisions
(Created page with "This functions destroys a vehicle. == Syntax == <syntaxhighlight lang="javascript"> Vehicle vehicle.destroy() </syntaxhighlight> == Example == Destroys a random vehicle from c...") |
No edit summary |
||
| Line 1: | Line 1: | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
mp.events.add('playerCommand', (player, cmd) => { | mp.events.add('playerCommand', (player, cmd) => { | ||
let arr = cmd.split(' '); | let arr = cmd.split(' '); | ||
if (arr[0] == 'destroyrandomveh' | if (arr[0] == 'destroyrandomveh') { | ||
let vehicles = mp.vehicles.toArray(); | let vehicles = mp.vehicles.toArray(); | ||
let randomValue = Math.floor(Math.random() * vehicles.length); | let randomValue = Math.floor(Math.random() * vehicles.length); | ||
Revision as of 13:39, 5 January 2017
mp.events.add('playerCommand', (player, cmd) => {
let arr = cmd.split(' ');
if (arr[0] == 'destroyrandomveh') {
let vehicles = mp.vehicles.toArray();
let randomValue = Math.floor(Math.random() * vehicles.length);
vehicles[randomValue].destroy();
}
});