Vehicle::destroy: Difference between revisions

From RAGE Multiplayer Wiki
(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:
This functions destroys a vehicle.
== Syntax ==
<syntaxhighlight lang="javascript">
Vehicle vehicle.destroy()
</syntaxhighlight>
== Example ==
Destroys a random vehicle from command.
<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' && player.vehicle) {
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();
	}
});