Taximeter fix clientside

This commit is contained in:
Siga
2020-03-13 14:53:49 +01:00
parent 6467615a32
commit 05a95dcb86
4 changed files with 4 additions and 8 deletions

View File

@@ -34,12 +34,9 @@ export default function taximeterInput(globalData: GlobalData) {
});
function myTimer() {
mp.gui.chat.push("" + totalPrice);
//if (mp.players.local.vehicle.getNumberOfPassengers() == 0) return;
if (totalPrice == lastPrice) return;
let payPrice = +totalPrice - +lastPrice;
lastPrice = totalPrice;
mp.gui.chat.push("" + totalPrice);
mp.events.callRemote("SERVER:payFare", payPrice, lastkilometer);
}
@@ -57,7 +54,6 @@ export default function taximeterInput(globalData: GlobalData) {
});
mp.events.add("CLIENT:updateFare", (km) => {
mp.gui.chat.push("" + lastkilometer)
browser.execute(`updateKilometer('${JSON.parse(km)}')`)
});

View File

@@ -139,7 +139,7 @@ export default function keys(globalData: GlobalData) {
}
});
//2 // Job Starten
//J // Job Starten
mp.keys.bind(0x4A, false, () => {
if (!globalData.InChat && !globalData.InInput && !globalData.InMenu && globalData.LoggedIn) {
mp.events.callRemote("CLIENT:JobManager_ShowJobMenu");

View File

@@ -8,6 +8,7 @@ const PRICE_KM = document.getElementById("taximeter-price-kilometer");
const KILOMETER = document.getElementById("taximeter-kilometer");
function updateKilometer(km) {
lastKilometer = +lastKilometer + +km;
UpdateTotalPrice();
KILOMETER.innerHTML = (Math.round((lastKilometer + Number.EPSILON) * 1000) / 1000).toString();
}
@@ -15,9 +16,8 @@ function updateKilometer(km) {
function UpdateTotalPrice() {
var TotalPrice = +lastKilometer * + price;
console.log(+lastKilometer * + price);
TOTAL_PRICE.innerHTML = Math.floor(TotalPrice).toString();
//mp.trigger("CEF:updateLastPrice", Math.floor(TotalPrice), Math.round((lastKilometer + Number.EPSILON) * 1000) / 1000);
mp.trigger("CEF:updateLastPrice", Math.floor(TotalPrice), Math.round((lastKilometer + Number.EPSILON) * 1000) / 1000);
}
function updateFarePrice() {