Add Taximeter
This commit is contained in:
@@ -10,24 +10,24 @@ export default function playerList(globalData: GlobalData): void {
|
||||
var pList;
|
||||
|
||||
mp.events.add("showPlayerlist", (playersJson) => {
|
||||
if (!globalData.InMenu) {
|
||||
if (playerlistBrowser === null) {
|
||||
|
||||
playerlistBrowser = mp.browsers.new('package://assets/html/Playerlist/Tabliste.html');
|
||||
mp.gui.chat.activate(false);
|
||||
mp.gui.cursor.show(true, true);
|
||||
pList = JSON.parse(playersJson);
|
||||
pList.forEach((player) => {
|
||||
playerlistBrowser.execute(`ad_row('${JSON.stringify(player.Id)}','${JSON.stringify(player.Name)}',0,0,'${JSON.stringify(player.Ping)}');`);
|
||||
});
|
||||
|
||||
} else {
|
||||
playerlistBrowser.destroy()
|
||||
playerlistBrowser = null;
|
||||
mp.gui.cursor.show(false, false);
|
||||
mp.gui.chat.activate(true);
|
||||
}
|
||||
|
||||
if (playerlistBrowser === null) {
|
||||
playerlistBrowser.destroy()
|
||||
playerlistBrowser = null;
|
||||
globalData.InInput = false;
|
||||
mp.gui.cursor.show(false, false);
|
||||
mp.gui.chat.activate(true);
|
||||
}
|
||||
if (!globalData.InInput) {
|
||||
globalData.InInput = true;
|
||||
playerlistBrowser = mp.browsers.new('package://assets/html/Playerlist/Tabliste.html');
|
||||
mp.gui.chat.activate(false);
|
||||
mp.gui.cursor.show(true, true);
|
||||
pList = JSON.parse(playersJson);
|
||||
pList.forEach((player) => {
|
||||
playerlistBrowser.execute(`ad_row('${JSON.stringify(player.Id)}','${JSON.stringify(player.Name)}',0,0,'${JSON.stringify(player.Ping)}');`);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("CEF:fetchPlayerList", () => {
|
||||
|
||||
75
ReallifeGamemode.Client/Gui/taximeter.ts
Normal file
75
ReallifeGamemode.Client/Gui/taximeter.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import InputHelper from '../inputhelper';
|
||||
|
||||
let browser: BrowserMp;
|
||||
let price: Number;
|
||||
|
||||
let lastkilometer: Number = 0;
|
||||
let lastPrice: Number = 0;
|
||||
let totalPrice: Number = 0;
|
||||
var myVar;
|
||||
export default function taximeterInput(globalData: GlobalData) {
|
||||
mp.events.add("CLIENT:setFarePrice", () => {
|
||||
/*
|
||||
var textBox = new InputHelper("Setzen Sie ihre Fahrtkosten [2 - 50 $/km]", globalData);
|
||||
textBox.show();
|
||||
textBox.getValue((data) => {
|
||||
var amount = parseInt(data);
|
||||
if (isNaN(amount)) {
|
||||
mp.game.graphics.notify('~r~Du musst eine Nummer eingeben!');
|
||||
return;
|
||||
}
|
||||
price = amount;
|
||||
mp.events.callRemote("SERVER:setFare", amount);
|
||||
});
|
||||
}
|
||||
*/
|
||||
mp.events.callRemote("SERVER:setFare", 60);
|
||||
price = 60;
|
||||
});
|
||||
|
||||
mp.events.add("CLIENT:startFare", () => {
|
||||
browser = mp.browsers.new('package://assets/html/taximeter/index.html');
|
||||
browser.execute(`setFarePrice('${price}');`)
|
||||
myVar = setInterval(myTimer, 100);
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
mp.events.add("CEF:updateLastPrice", (price, lastkilometer1) => {
|
||||
totalPrice = price
|
||||
lastkilometer = lastkilometer1;
|
||||
});
|
||||
|
||||
|
||||
mp.events.add("CLIENT:startCustomerFare", (price1, km) => {
|
||||
browser = mp.browsers.new('package://assets/html/taximeter/index.html');
|
||||
browser.execute(`setFarePrice('${price1}');`);
|
||||
browser.execute(`updateKilometer('${km}')`);
|
||||
|
||||
});
|
||||
|
||||
mp.events.add("CLIENT:updateFare", (km) => {
|
||||
mp.gui.chat.push("" + lastkilometer)
|
||||
browser.execute(`updateKilometer('${JSON.parse(km)}')`)
|
||||
});
|
||||
|
||||
|
||||
mp.events.add("CLIENT:cancelFareCustomer", () => { //for Customer
|
||||
mp.events.callRemote("SERVER:cancelFareCustomer", lastPrice);
|
||||
browser.destroy();
|
||||
browser = null;
|
||||
});
|
||||
|
||||
mp.events.add("CLIENT:cancelFare", () => { //for Taxidriver
|
||||
browser.destroy();
|
||||
browser = null;
|
||||
});
|
||||
}
|
||||
64
ReallifeGamemode.Client/assets/css/taximeter/main.css
Normal file
64
ReallifeGamemode.Client/assets/css/taximeter/main.css
Normal file
@@ -0,0 +1,64 @@
|
||||
@font-face {
|
||||
font-family: DS-Digital;
|
||||
src: url(../../font/taximeter/DS-Digital.woff2) format("woff2"),url(../../font/taximeter/DS-Digital.woff) format("woff");
|
||||
font-weight: 400;
|
||||
font-style: normal
|
||||
}
|
||||
|
||||
body {
|
||||
width: 640px
|
||||
}
|
||||
|
||||
h4 {
|
||||
margin: 0
|
||||
}
|
||||
|
||||
.taximeter-company {
|
||||
background-color: #171717;
|
||||
max-width: 100%
|
||||
}
|
||||
|
||||
.taximeter-company__header {
|
||||
text-align: center;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-size: 170%;
|
||||
font-family: DS-Digital;
|
||||
color: #ff0
|
||||
}
|
||||
|
||||
.taximeter {
|
||||
max-width: 100%;
|
||||
height: 80px;
|
||||
padding: 1em;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
background-color: #171717
|
||||
}
|
||||
|
||||
.taximeter-element {
|
||||
margin: 3px;
|
||||
width: 200px;
|
||||
height: 50px
|
||||
}
|
||||
|
||||
.taximeter-header {
|
||||
font-size: 170%;
|
||||
color: red;
|
||||
font-family: DS-Digital
|
||||
}
|
||||
|
||||
.taximeter-output {
|
||||
height: 40px;
|
||||
max-width: 100%;
|
||||
margin: 0;
|
||||
font-family: DS-Digital;
|
||||
font-size: 250%;
|
||||
color: red;
|
||||
display: block
|
||||
}
|
||||
|
||||
.taximeter-output__additional {
|
||||
font-size: 70%
|
||||
}
|
||||
/*# sourceMappingURL=main.css.map */
|
||||
BIN
ReallifeGamemode.Client/assets/font/taximeter/DS-Digital.woff
Normal file
BIN
ReallifeGamemode.Client/assets/font/taximeter/DS-Digital.woff
Normal file
Binary file not shown.
BIN
ReallifeGamemode.Client/assets/font/taximeter/DS-Digital.woff2
Normal file
BIN
ReallifeGamemode.Client/assets/font/taximeter/DS-Digital.woff2
Normal file
Binary file not shown.
38
ReallifeGamemode.Client/assets/html/taximeter/index.html
Normal file
38
ReallifeGamemode.Client/assets/html/taximeter/index.html
Normal file
@@ -0,0 +1,38 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Taximeter</title>
|
||||
<link rel="stylesheet" href="../../css/taximeter/main.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="taximeter-company">
|
||||
<p class="taximeter-company__header">Downtown Cab Co.</p>
|
||||
</div>
|
||||
<div class="taximeter">
|
||||
<div class="taximeter-element">
|
||||
<h4 class="taximeter-header">Kilometer</h4>
|
||||
<p class="taximeter-output">
|
||||
<span id="taximeter-kilometer"></span>
|
||||
<span class="taximeter-output__additional">KM</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="taximeter-element">
|
||||
<h4 class="taximeter-header">Preis / KM</h4>
|
||||
<p class="taximeter-output">
|
||||
<span id="taximeter-price-kilometer"></span>
|
||||
<span class="taximeter-output__additional">$</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="taximeter-element">
|
||||
<h4 class="taximeter-header">Preis</h4>
|
||||
<p class="taximeter-output">
|
||||
<span id="taximeter-price"></span>
|
||||
<span class="taximeter-output__additional">$</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script src="../../js/taximeter/main.js"></script>
|
||||
</html>
|
||||
36
ReallifeGamemode.Client/assets/js/taximeter/main.js
Normal file
36
ReallifeGamemode.Client/assets/js/taximeter/main.js
Normal file
@@ -0,0 +1,36 @@
|
||||
var lastKilometer = 0;
|
||||
var price;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () { });
|
||||
|
||||
const TOTAL_PRICE = document.getElementById("taximeter-price");
|
||||
const PRICE_KM = document.getElementById("taximeter-price-kilometer");
|
||||
const KILOMETER = document.getElementById("taximeter-kilometer");
|
||||
|
||||
function updateKilometer(km) {
|
||||
UpdateTotalPrice();
|
||||
KILOMETER.innerHTML = (Math.round((lastKilometer + Number.EPSILON) * 1000) / 1000).toString();
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
function updateFarePrice() {
|
||||
document.getElementById("taximeter-price-kilometer").innerHTML = price.toString();
|
||||
document.getElementById("taximeter-kilometer").innerHTML = "-";
|
||||
document.getElementById("taximeter-price").innerHTML = "0";
|
||||
}
|
||||
|
||||
function setFarePrice(price1) {
|
||||
price = price1;
|
||||
updateFarePrice();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -188,4 +188,7 @@ import clotheShopList from './Interaction/clothes/ClotheShop';
|
||||
clotheShopList(globalData);
|
||||
|
||||
import itemShopList from './Interaction/ItemShop';
|
||||
itemShopList(globalData);
|
||||
itemShopList(globalData);
|
||||
|
||||
import taximeterInput from './Gui/taximeter';
|
||||
taximeterInput(globalData);
|
||||
@@ -10,7 +10,6 @@ export default function inventory(globalData: GlobalData): void {
|
||||
|
||||
var ivehArr;
|
||||
|
||||
|
||||
var Players;
|
||||
|
||||
mp.events.add('setVehiclesInventory', (vehInvArr) => {
|
||||
@@ -23,33 +22,23 @@ export default function inventory(globalData: GlobalData): void {
|
||||
});
|
||||
var open = false;
|
||||
mp.events.add('inventoryShow', (iWeight, iNameArr, iAmountArr, iIdArr, playersArr) => {
|
||||
if (!globalData.InMenu) {
|
||||
globalData.InMenu = true;
|
||||
if (invBrowser === null) {
|
||||
|
||||
|
||||
mp.gui.cursor.show(true, true);
|
||||
invBrowser = mp.browsers.new('package://assets/html/inventory/inventory.html');
|
||||
Players = playersArr;
|
||||
itemIdArr = iIdArr;
|
||||
itemAmountArr = iAmountArr;
|
||||
itemNameArr = iNameArr;
|
||||
invWeight = iWeight;
|
||||
|
||||
} else {
|
||||
|
||||
try {
|
||||
invBrowser.destroy()
|
||||
invBrowser = null;
|
||||
globalData.InMenu = false;
|
||||
}
|
||||
finally {
|
||||
mp.gui.cursor.show(false, false);
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
if (invBrowser !== null) {
|
||||
invBrowser.destroy()
|
||||
invBrowser = null;
|
||||
globalData.InInput = false;
|
||||
mp.gui.cursor.show(false, false);
|
||||
return;
|
||||
}
|
||||
if (!globalData.InInput) {
|
||||
globalData.InInput = true;
|
||||
mp.gui.cursor.show(true, true);
|
||||
invBrowser = mp.browsers.new('package://assets/html/inventory/inventory.html');
|
||||
Players = playersArr;
|
||||
itemIdArr = iIdArr;
|
||||
itemAmountArr = iAmountArr;
|
||||
itemNameArr = iNameArr;
|
||||
invWeight = iWeight;
|
||||
}
|
||||
});
|
||||
var offer = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user