Added tuning support for colored lights

This commit is contained in:
hydrant
2018-12-15 14:00:01 +01:00
parent 7a5f820068
commit 2818fd3513
5 changed files with 139 additions and 26 deletions

View File

@@ -0,0 +1,19 @@
function setHeadlightsColor(vehicle, color) {
if (typeof color !== "number" || isNaN(color) || color < 0 || color === 255) {
// Disable
vehicle.toggleMod(22, false);
mp.game.invoke("0xE41033B25D003A07", vehicle.handle, 255);
} else {
// Enable
vehicle.toggleMod(22, true);
mp.game.invoke("0xE41033B25D003A07", vehicle.handle, color);
}
}
mp.events.add("entityStreamIn", (entity) => {
if (entity.type === "vehicle") setHeadlightsColor(entity, parseInt(entity.getVariable("headlightColor")));
});
mp.events.addDataHandler("headlightColor", (entity, value) => {
if (entity.type === "vehicle") setHeadlightsColor(entity, value);
});