Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
Added a simple command to tune a single mod on a vehicle (#410)
Browse files Browse the repository at this point in the history
* vehicle singelTune command
  • Loading branch information
Dav-Renz committed Apr 6, 2023
1 parent bde990b commit 3dbae04
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,48 @@ Athena.systems.messenger.commands.register(
},
);

Athena.systems.messenger.commands.register(
'tunevehicle',
'/tunevehicle [modID] [value] - Sets the specified Mod to the given value',
['admin'],
(player: alt.Player, id: number, value: number) => {
const vehicle = player.vehicle ? player.vehicle : Athena.utility.closest.getClosestVehicle(player.pos);

if (!vehicle) {
Athena.player.emit.message(player, 'No spawned vehicle.');
return;
}

if (Athena.utility.vector.distance(player.pos, vehicle.pos) > 4) {
Athena.player.emit.message(player, 'No vehicle in range.');
return;
}

if (vehicle.modKit == 0 && vehicle.modKitsCount > 0) {
Athena.vehicle.tuning.applyTuning(vehicle, { modkit: 1 });
}

if (vehicle.modKit == 0) {
Athena.player.emit.message(player, LocaleController.get(LOCALE_KEYS.VEHICLE_HAS_NO_MOD_KIT));
return;
}

Athena.vehicle.tuning.applyTuning(vehicle, { mods: [{ id, value }] });
Athena.vehicle.controls.updateLastUsed(vehicle);
Athena.vehicle.controls.update(vehicle);

const tuningData: IVehicleTuning = Athena.vehicle.tuning.getTuning(vehicle);

Athena.document.vehicle.set(vehicle, 'tuning', tuningData);

const hash = typeof vehicle.model === 'number' ? vehicle.model : alt.hash(vehicle.model);

let vehInfo = Athena.utility.hashLookup.vehicle.hash(hash);

Athena.player.emit.message(player, `Mod ID: ${id} of ${vehInfo.displayName} was set to ${value}.`);
},
);

// import { command } from '@AthenaServer/decorators/commands';
// import { PERMISSIONS } from '@AthenaShared/flags/permissionFlags';
// import { LOCALE_KEYS } from '@AthenaShared/locale/languages/keys';
Expand Down

0 comments on commit 3dbae04

Please sign in to comment.