55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
export default function tuningSync() {
|
|
mp.events.add('entityStreamIn', (entity: EntityMp) => {
|
|
if (!entity) {
|
|
return;
|
|
}
|
|
if (entity.isAVehicle()) {
|
|
|
|
var vehicle: VehicleMp = entity as VehicleMp;
|
|
|
|
var taxiLight = entity.getVariable("vehicleTaxiLight");
|
|
if (taxiLight) vehicle.setTaxiLights(taxiLight);
|
|
|
|
var mod18 = vehicle.getVariable('mod18');
|
|
var wheelType = vehicle.getVariable('wheelType');
|
|
|
|
if (wheelType !== undefined) {
|
|
setWheelType(vehicle, wheelType);
|
|
}
|
|
|
|
if (mod18 !== undefined) {
|
|
vehicle.toggleMod(18, mod18);
|
|
}
|
|
}
|
|
});
|
|
|
|
mp.events.add('vehicleToggleMod', (veh, slot, newval) => {
|
|
if (!veh) {
|
|
return;
|
|
}
|
|
if (slot == -2) {
|
|
setWheelType(veh, newval);
|
|
}
|
|
else {
|
|
veh.toggleMod(slot, newval);
|
|
}
|
|
|
|
});
|
|
|
|
function setWheelType(vehicle, wheelType) {
|
|
setTimeout(() => {
|
|
if (mp.vehicles.exists(vehicle)) {
|
|
var mod = vehicle.getMod(23);
|
|
vehicle.setWheelType(wheelType);
|
|
vehicle.setMod(23, mod);
|
|
}
|
|
}, 1000);
|
|
}
|
|
|
|
mp.events.addDataHandler("vehicleTaxiLight", (entity: VehicleMp, state: boolean) => {
|
|
if (!entity) {
|
|
return;
|
|
}
|
|
entity.setTaxiLights(state);
|
|
});
|
|
} |