Vehicle::destroy

From RAGE Multiplayer Wiki
Revision as of 13:39, 5 January 2017 by Niks (talk | contribs) (Created page with "This functions destroys a vehicle. == Syntax == <syntaxhighlight lang="javascript"> Vehicle vehicle.destroy() </syntaxhighlight> == Example == Destroys a random vehicle from c...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This functions destroys a vehicle.

Syntax

Vehicle vehicle.destroy()

Example

Destroys a random vehicle from command.

mp.events.add('playerCommand', (player, cmd) => {
	let arr = cmd.split(' ');
	if (arr[0] == 'destroyrandomveh' && player.vehicle) {
		let vehicles = mp.vehicles.toArray();
		let randomValue = Math.floor(Math.random() * vehicles.length);
		vehicles[randomValue].destroy();
	}
});