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

Commit

Permalink
fix: proper fuel indicator showup
Browse files Browse the repository at this point in the history
  • Loading branch information
demxnn committed Feb 22, 2022
1 parent 38f6ef0 commit 0b202e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
7 changes: 4 additions & 3 deletions nui/assets/js/listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const HealthIcon = document.getElementById('HealthIcon');
const SpeedIcon = document.getElementById('SpeedIcon');
const VoiceIcon = document.getElementById('VoiceIcon');
const OxygenIcon = document.getElementById('OxygenIcon');
const FuelIcon = document.getElementById('FuelIcon');
const HungerIcon = document.getElementById('HungerIcon');
const ThirstIcon = document.getElementById('ThirstIcon');
const StressIcon = document.getElementById('StressIcon');
Expand Down Expand Up @@ -85,21 +86,21 @@ window.addEventListener('message', function (event) {
if (action == 'setVehicle') {
if (data) {
Speed.style.display = 'block';
Fuel.style.display = 'block';

let speed = data.speed.current * data.unitsMultiplier;
let maxSpeed = data.speed.max * data.unitsMultiplier;
let percSpeed = (speed / maxSpeed) * 0.7;
let fuel = data.fuel && data.fuel / 100;

percSpeed > 1 && (percSpeed = 1);

percSpeed >= 0.01 && SpeedIcon.classList.remove('fa-tachometer-alt');
percSpeed >= 0.01 && (SpeedIcon.textContent = Math.floor(speed));
percSpeed < 0.01 && SpeedIcon.classList.add('fa-tachometer-alt');
percSpeed < 0.01 && (SpeedIcon.textContent = '');

Circle.FuelIndicator.path.setAttribute('stroke', fuel > 0.2 ? 'rgb(255, 255, 255)' : 'rgb(255, 0, 0)');
Fuel.style.display = fuel !== false ? 'block' : 'none';
fuel <= 0.15 && FuelIcon.classList.toggle('flash');
Circle.FuelIndicator.path.setAttribute('stroke', fuel > 0.15 ? 'rgb(255, 255, 255)' : 'rgb(255, 0, 0)');

Circle.SpeedIndicator.animate(percSpeed);
Circle.FuelIndicator.animate(fuel);
Expand Down
6 changes: 0 additions & 6 deletions nui/assets/js/main.js

This file was deleted.

0 comments on commit 0b202e1

Please # to comment.