Add Taximeter
This commit is contained in:
BIN
Import/Newtonsoft.Json.dll
Normal file
BIN
Import/Newtonsoft.Json.dll
Normal file
Binary file not shown.
@@ -10,24 +10,24 @@ export default function playerList(globalData: GlobalData): void {
|
|||||||
var pList;
|
var pList;
|
||||||
|
|
||||||
mp.events.add("showPlayerlist", (playersJson) => {
|
mp.events.add("showPlayerlist", (playersJson) => {
|
||||||
if (!globalData.InMenu) {
|
|
||||||
if (playerlistBrowser === null) {
|
if (playerlistBrowser === null) {
|
||||||
|
playerlistBrowser.destroy()
|
||||||
playerlistBrowser = mp.browsers.new('package://assets/html/Playerlist/Tabliste.html');
|
playerlistBrowser = null;
|
||||||
mp.gui.chat.activate(false);
|
globalData.InInput = false;
|
||||||
mp.gui.cursor.show(true, true);
|
mp.gui.cursor.show(false, false);
|
||||||
pList = JSON.parse(playersJson);
|
mp.gui.chat.activate(true);
|
||||||
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 (!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", () => {
|
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);
|
clotheShopList(globalData);
|
||||||
|
|
||||||
import itemShopList from './Interaction/ItemShop';
|
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 ivehArr;
|
||||||
|
|
||||||
|
|
||||||
var Players;
|
var Players;
|
||||||
|
|
||||||
mp.events.add('setVehiclesInventory', (vehInvArr) => {
|
mp.events.add('setVehiclesInventory', (vehInvArr) => {
|
||||||
@@ -23,33 +22,23 @@ export default function inventory(globalData: GlobalData): void {
|
|||||||
});
|
});
|
||||||
var open = false;
|
var open = false;
|
||||||
mp.events.add('inventoryShow', (iWeight, iNameArr, iAmountArr, iIdArr, playersArr) => {
|
mp.events.add('inventoryShow', (iWeight, iNameArr, iAmountArr, iIdArr, playersArr) => {
|
||||||
if (!globalData.InMenu) {
|
if (invBrowser !== null) {
|
||||||
globalData.InMenu = true;
|
invBrowser.destroy()
|
||||||
if (invBrowser === null) {
|
invBrowser = null;
|
||||||
|
globalData.InInput = false;
|
||||||
|
mp.gui.cursor.show(false, false);
|
||||||
mp.gui.cursor.show(true, true);
|
return;
|
||||||
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 (!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;
|
var offer = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace ReallifeGamemode.Database.Entities
|
namespace ReallifeGamemode.Database.Entities
|
||||||
{
|
{
|
||||||
public partial class JobVehicle : ServerVehicle
|
public partial class JobVehicle : ServerVehicle
|
||||||
{
|
{
|
||||||
public int JobId { get; set; }
|
public int JobId { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,9 @@
|
|||||||
<Reference Include="Bootstrapper">
|
<Reference Include="Bootstrapper">
|
||||||
<HintPath>..\Import\Bootstrapper.dll</HintPath>
|
<HintPath>..\Import\Bootstrapper.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Newtonsoft.Json">
|
||||||
|
<HintPath>..\Import\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace ReallifeGamemode.Server.Extensions
|
|||||||
|
|
||||||
public static Player GetDriver(this Vehicle veh)
|
public static Player GetDriver(this Vehicle veh)
|
||||||
{
|
{
|
||||||
return NAPI.Pools.GetAllPlayers().Where(p => p.Vehicle.Handle == veh.Handle && p.VehicleSeat == -1).FirstOrDefault();
|
return NAPI.Pools.GetAllPlayers().Where(p => p.Vehicle.Handle == veh.Handle && p.VehicleSeat == 0).FirstOrDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,9 +187,9 @@ namespace ReallifeGamemode.Server.Finance
|
|||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
}
|
}
|
||||||
if (paycheck.Amount > 0)
|
if (paycheck.Amount > 0)
|
||||||
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Du hast einen Payday von ~g~$" + paycheck.Amount + "~s~ bekommen.");
|
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt + $~g~" + paycheck.Amount + "~s~.");
|
||||||
else
|
else
|
||||||
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Du hast einen Payday von ~r~$" + paycheck.Amount + "~s~ bekommen.");
|
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt - $~r~" + paycheck.Amount + "~s~.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ namespace ReallifeGamemode.Server.Job
|
|||||||
public event JobStopHandler JobStop;
|
public event JobStopHandler JobStop;
|
||||||
|
|
||||||
private readonly List<Player> _inJob = new List<Player>();
|
private readonly List<Player> _inJob = new List<Player>();
|
||||||
|
private static readonly List<Player> jobPlayer = new List<Player>();
|
||||||
|
|
||||||
public abstract int Id { get; }
|
public abstract int Id { get; }
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ namespace ReallifeGamemode.Server.Job
|
|||||||
{
|
{
|
||||||
if (_inJob.Contains(player)) return;
|
if (_inJob.Contains(player)) return;
|
||||||
_inJob.Add(player);
|
_inJob.Add(player);
|
||||||
|
jobPlayer.Add(player);
|
||||||
|
|
||||||
ChatService.SendMessage(player, $"~y~[JOB]~s~ Du hast deinen Job ~o~{this.Name}~s~ gestartet.");
|
ChatService.SendMessage(player, $"~y~[JOB]~s~ Du hast deinen Job ~o~{this.Name}~s~ gestartet.");
|
||||||
|
|
||||||
@@ -37,6 +39,7 @@ namespace ReallifeGamemode.Server.Job
|
|||||||
{
|
{
|
||||||
if (!_inJob.Contains(player)) return;
|
if (!_inJob.Contains(player)) return;
|
||||||
_inJob.Remove(player);
|
_inJob.Remove(player);
|
||||||
|
jobPlayer.Remove(player);
|
||||||
|
|
||||||
if (quit)
|
if (quit)
|
||||||
{
|
{
|
||||||
@@ -54,6 +57,7 @@ namespace ReallifeGamemode.Server.Job
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Player> GetPlayerInJob() => jobPlayer;
|
||||||
public List<Player> GetUsersInJob() => _inJob;
|
public List<Player> GetUsersInJob() => _inJob;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,14 @@ using System.Collections.Generic;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using GTANetworkAPI;
|
using GTANetworkAPI;
|
||||||
using ReallifeGamemode.Server.Util;
|
using ReallifeGamemode.Server.Util;
|
||||||
|
using ReallifeGamemode.Server.Services;
|
||||||
|
using ReallifeGamemode.Server.Extensions;
|
||||||
|
using System.Timers;
|
||||||
|
using ReallifeGamemode.Database.Models;
|
||||||
|
using ReallifeGamemode.Server.Managers;
|
||||||
|
using ReallifeGamemode.Database.Entities;
|
||||||
|
using System.Linq;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace ReallifeGamemode.Server.Job
|
namespace ReallifeGamemode.Server.Job
|
||||||
{
|
{
|
||||||
@@ -10,26 +18,109 @@ namespace ReallifeGamemode.Server.Job
|
|||||||
{
|
{
|
||||||
public List<TaxiContract> TaxiContracts { get; set; } = new List<TaxiContract>();
|
public List<TaxiContract> TaxiContracts { get; set; } = new List<TaxiContract>();
|
||||||
|
|
||||||
|
private static readonly Dictionary<NetHandle, Vector3> lastPositions = new Dictionary<NetHandle, Vector3>();
|
||||||
|
|
||||||
public override int Id => 1;
|
public override int Id => 1;
|
||||||
|
|
||||||
public override string Name => "Taxifahrer";
|
public override string Name => "Taxifahrer";
|
||||||
|
|
||||||
public override bool NeedVehicleToStart => true;
|
public override bool NeedVehicleToStart => true;
|
||||||
|
|
||||||
|
|
||||||
|
private static TaxiDriverJob _Instance;
|
||||||
|
|
||||||
public TaxiDriverJob()
|
public TaxiDriverJob()
|
||||||
{
|
{
|
||||||
JobStart += TaxiDriverJobJobStart;
|
JobStart += TaxiDriverJobJobStart;
|
||||||
JobStop += TaxiDriverJobJobStop;
|
JobStop += TaxiDriverJobJobStop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TaxiDriverJob GetInstance()
|
||||||
|
{
|
||||||
|
if (_Instance == null)
|
||||||
|
_Instance = new TaxiDriverJob();
|
||||||
|
return _Instance;
|
||||||
|
}
|
||||||
private void TaxiDriverJobJobStart(Player player)
|
private void TaxiDriverJobJobStart(Player player)
|
||||||
{
|
{
|
||||||
player.Vehicle.SetSharedData("vehicleTaxiLight", true);
|
player.Vehicle.SetSharedData("vehicleTaxiLight", true);
|
||||||
|
player.TriggerEvent("CLIENT:setFarePrice");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TaxiDriverJobJobStop(Player player)
|
private void TaxiDriverJobJobStop(Player player)
|
||||||
{
|
{
|
||||||
player.Vehicle.SetSharedData("vehicleTaxiLight", false);
|
player.Vehicle.SetSharedData("vehicleTaxiLight", false);
|
||||||
|
int Id = player.GetUser().Id;
|
||||||
|
player.ResetData("DriverPrice");
|
||||||
|
Vehicle v = player.Vehicle;
|
||||||
|
|
||||||
|
foreach (Player occupant in v.Occupants)
|
||||||
|
{
|
||||||
|
occupant.TriggerEvent("CLIENT:cancelFare");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("SERVER:failedFarePrice")]
|
||||||
|
private void SrvEvent_failedFarePrice(Player player)
|
||||||
|
{
|
||||||
|
ChatService.ErrorMessage(player, "Bitte richtigen Wert eintragen");
|
||||||
|
TaxiDriverJobJobStop(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("SERVER:setFare")]
|
||||||
|
private void SrvEvent_setFare(Player player, int amount)
|
||||||
|
{
|
||||||
|
player.SetData<int>("DriverPrice", amount);
|
||||||
|
player.TriggerEvent("CLIENT:startFare");
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("SERVER:payFare")]
|
||||||
|
private void SrvEvent_payFare(Player player, int amount, float km)
|
||||||
|
{
|
||||||
|
int id = player.GetUser().Id;
|
||||||
|
player.SetData<float>("FareKm", km);
|
||||||
|
int targetId = player.GetData<int>("Passager");
|
||||||
|
if (targetId == 0) return;
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
User target = dbContext.Users.Where(u => u.Id == targetId).FirstOrDefault();
|
||||||
|
target.Handmoney -= amount;
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
target.Player.TriggerEvent("SERVER:SET_HANDMONEY", target.Handmoney);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void StartTaxiTimer()
|
||||||
|
{
|
||||||
|
Timer timer = new Timer(1000);
|
||||||
|
timer.Start();
|
||||||
|
timer.Elapsed += UpdateFare;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void UpdateFare(object sender, ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
foreach(var player in GetPlayerInJob())
|
||||||
|
{
|
||||||
|
if (!player.HasData("hasPassager")) { player.SetData<bool>("hasPassager", false); continue; }
|
||||||
|
int playerId = player.GetUser().Id;
|
||||||
|
|
||||||
|
Vehicle v = player.Vehicle;
|
||||||
|
|
||||||
|
Vector3 lastPosition = v.Position;
|
||||||
|
if (lastPositions.ContainsKey(v.Handle)) lastPosition = lastPositions[v.Handle];
|
||||||
|
lastPositions[v.Handle] = v.Position;
|
||||||
|
|
||||||
|
double distance = lastPosition.DistanceTo(v.Position) / 1000.0;
|
||||||
|
if (distance > 0.5) { ChatService.BroadcastAdmin($"Möglicher Cheater - {player.Name}", Database.AdminLevel.MAPPING); continue; }
|
||||||
|
if (!player.GetData<bool>("hasPassager")) continue;
|
||||||
|
foreach (Player occupant in v.Occupants)
|
||||||
|
{
|
||||||
|
occupant.TriggerEvent("CLIENT:updateFare", JsonConvert.SerializeObject(distance));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using ReallifeGamemode.Server.Util;
|
|||||||
using ReallifeGamemode.Server.Wanted;
|
using ReallifeGamemode.Server.Wanted;
|
||||||
using ReallifeGamemode.Server.DrivingSchool;
|
using ReallifeGamemode.Server.DrivingSchool;
|
||||||
using ReallifeGamemode.Server.WeaponDeal;
|
using ReallifeGamemode.Server.WeaponDeal;
|
||||||
|
using ReallifeGamemode.Server.Job;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @overview Life of German Reallife - Main Class (Main.cs)
|
* @overview Life of German Reallife - Main Class (Main.cs)
|
||||||
@@ -60,6 +61,7 @@ namespace ReallifeGamemode.Server
|
|||||||
ATMManager.InitATMs();
|
ATMManager.InitATMs();
|
||||||
CityHallManager.LoadCityHall();
|
CityHallManager.LoadCityHall();
|
||||||
JobManager.LoadJobs();
|
JobManager.LoadJobs();
|
||||||
|
TaxiDriverJob.StartTaxiTimer();
|
||||||
HouseManager.LoadHouses();
|
HouseManager.LoadHouses();
|
||||||
DrivingSchool.DrivingSchool.Setup();
|
DrivingSchool.DrivingSchool.Setup();
|
||||||
PlaneSchool.Setup();
|
PlaneSchool.Setup();
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
|||||||
|
|
||||||
namespace ReallifeGamemode.Server.Managers
|
namespace ReallifeGamemode.Server.Managers
|
||||||
{
|
{
|
||||||
class JobManager : Script
|
public class JobManager : Script
|
||||||
{
|
{
|
||||||
private static List<JobBase> _jobs = new List<JobBase>();
|
private static List<JobBase> _jobs = new List<JobBase>();
|
||||||
|
|
||||||
@@ -30,9 +30,8 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
throw new InvalidOperationException($"Double Job ID found: {instance.Id} | {instance.Name}");
|
throw new InvalidOperationException($"Double Job ID found: {instance.Id} | {instance.Name}");
|
||||||
}
|
}
|
||||||
_jobs.Add(instance);
|
_jobs.Add(instance);
|
||||||
NAPI.Util.ConsoleOutput($"Loading job {instance.Name}");
|
NAPI.Util.ConsoleOutput($"Loading job {instance.Name}");
|
||||||
}
|
}
|
||||||
|
|
||||||
NAPI.Util.ConsoleOutput($"Loaded {_jobs.Count} jobs");
|
NAPI.Util.ConsoleOutput($"Loaded {_jobs.Count} jobs");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,28 +217,64 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
[ServerEvent(Event.PlayerEnterVehicle)]
|
[ServerEvent(Event.PlayerEnterVehicle)]
|
||||||
public void JobManagerPlayerEnterVehicle(Player player, Vehicle veh, sbyte seat)
|
public void JobManagerPlayerEnterVehicle(Player player, Vehicle veh, sbyte seat)
|
||||||
{
|
{
|
||||||
|
if (seat == 0) return;
|
||||||
ServerVehicle sVeh = veh.GetServerVehicle();
|
ServerVehicle sVeh = veh.GetServerVehicle();
|
||||||
if (sVeh == null) return;
|
if (sVeh == null) return;
|
||||||
if (sVeh is JobVehicle jV && jV.JobId == 1) // Spieler steigt in Taxi ein
|
if (sVeh is JobVehicle jV && jV.JobId == 1) // Spieler steigt in Taxi ein
|
||||||
{
|
{
|
||||||
var taxiJob = JobManager.GetJob<TaxiDriverJob>();
|
var taxiJob = JobManager.GetJob<TaxiDriverJob>();
|
||||||
|
|
||||||
|
Player driver = veh.GetDriver();
|
||||||
|
if (!driver.HasData("DriverPrice")) return;
|
||||||
|
int taxiPrice = driver.GetData<int>("DriverPrice");
|
||||||
|
|
||||||
|
float km = 0;
|
||||||
|
if (!driver.HasData("FareKm")) { driver.SetData<float>("FareKm", km); }
|
||||||
|
km = driver.GetData<float>("FareKm");
|
||||||
|
if (driver.HasData("Passager")) return;
|
||||||
|
driver.SetData<int>("Passager", player.GetUser().Id);
|
||||||
|
driver.SetData<bool>("hasPassager", true);
|
||||||
|
|
||||||
|
player.TriggerEvent("CLIENT:startCustomerFare", taxiPrice, km);
|
||||||
|
|
||||||
var taxiContracts = taxiJob.TaxiContracts.Where(t => t.Name == player.Name);
|
var taxiContracts = taxiJob.TaxiContracts.Where(t => t.Name == player.Name);
|
||||||
if (taxiContracts.Count() == 0) return;
|
if (taxiContracts.Count() == 0) return;
|
||||||
|
|
||||||
var contract = taxiContracts.First();
|
var contract = taxiContracts.First();
|
||||||
taxiJob.TaxiContracts.Remove(contract);
|
taxiJob.TaxiContracts.Remove(contract);
|
||||||
|
|
||||||
Player driver = veh.GetDriver();
|
if (driver != null && contract.Driver != null && contract.Driver.Handle != veh.GetDriver().Handle)
|
||||||
|
|
||||||
if (driver != null && contract.Driver.Handle != veh.GetDriver().Handle)
|
|
||||||
{
|
{
|
||||||
ChatService.SendMessage(contract.Driver, $"!{{02FCFF}}{player.Name} ist in ein Taxi eingestiegen, der Auftrag wurde beendet.");
|
ChatService.SendMessage(contract.Driver, $"!{{02FCFF}}{player.Name} ist in ein Taxi eingestiegen, der Auftrag wurde beendet.");
|
||||||
ChatService.SendMessage(player, $"!{{02FCFF}}Du bist in ein Taxi eingestiegen, der Auftrag wurde beendet.");
|
ChatService.SendMessage(player, $"!{{02FCFF}}Du bist in ein Taxi eingestiegen, der Auftrag wurde beendet.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[ServerEvent(Event.PlayerExitVehicle)]
|
||||||
|
public void JobManagerPlayerEnterVehicle(Player player, Vehicle veh)
|
||||||
|
{
|
||||||
|
ServerVehicle sVeh = veh.GetServerVehicle();
|
||||||
|
if (sVeh == null) return;
|
||||||
|
if (sVeh is JobVehicle jV && jV.JobId == 1) // Spieler steigt in Taxi aus
|
||||||
|
{
|
||||||
|
var taxiJob = JobManager.GetJob<TaxiDriverJob>();
|
||||||
|
if (veh.Occupants.Count == 0) return;
|
||||||
|
Player driver = veh.GetDriver();
|
||||||
|
if (driver == null) return;
|
||||||
|
if (player.GetUser().Id != driver.GetData<int>("Passager")) { player.TriggerEvent("CLIENT:cancelFare"); return; }
|
||||||
|
player.TriggerEvent("CLIENT:cancelFareCustomer");
|
||||||
|
driver.ResetData("Passager");
|
||||||
|
driver.ResetData("hasPassager");
|
||||||
|
foreach(Player occupant in veh.Occupants)
|
||||||
|
{
|
||||||
|
if (occupant == driver) continue;
|
||||||
|
occupant.WarpOutOfVehicle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[RemoteEvent("CLIENT:JobManager_TaxiJob_AcceptCall")]
|
[RemoteEvent("CLIENT:JobManager_TaxiJob_AcceptCall")]
|
||||||
public void TaxiJobAcceptCall(Player player, string name)
|
public void TaxiJobAcceptCall(Player player, string name)
|
||||||
{
|
{
|
||||||
@@ -264,8 +299,10 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
job.Driver = player;
|
job.Driver = player;
|
||||||
|
|
||||||
player.TriggerEvent("SERVER:Util_setWaypoint", target.Position.X, target.Position.Y);
|
player.TriggerEvent("SERVER:Util_setWaypoint", target.Position.X, target.Position.Y);
|
||||||
|
player.SetData<bool>("hasPassager", true);
|
||||||
|
|
||||||
ChatService.SendMessage(target, $"!{{02FCFF}}Dein Auftrag wurde von {player.Name} angenommen. Warte an deiner aktuellen Position.");
|
ChatService.SendMessage(target, $"!{{02FCFF}}Dein Auftrag wurde von {player.Name} angenommen. Warte an deiner aktuellen Position.");
|
||||||
|
ChatService.SendMessage(target, $"!{{02FCFF}}Für die Anfahrt fallen zusätzlich Kosten auf.");
|
||||||
ChatService.SendMessage(player, $"!{{02FCFF}}Du hast den Auftrag von {name} angenommen. Hole ihn nun ab.");
|
ChatService.SendMessage(player, $"!{{02FCFF}}Du hast den Auftrag von {name} angenommen. Hole ihn nun ab.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,9 @@
|
|||||||
<Reference Include="Bootstrapper">
|
<Reference Include="Bootstrapper">
|
||||||
<HintPath>..\Import\Bootstrapper.dll</HintPath>
|
<HintPath>..\Import\Bootstrapper.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Newtonsoft.Json">
|
||||||
|
<HintPath>..\Import\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(ConfigurationName)' != 'ServerBuild' AND '$(OS)' == 'Windows_NT'">
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(ConfigurationName)' != 'ServerBuild' AND '$(OS)' == 'Windows_NT'">
|
||||||
<Exec Command="powershell -NonInteractive -ExecutionPolicy ByPass -File ..\postbuild.ps1 -buildDirectory $(OutDir) -buildFilename $(TargetFileName)" LogStandardErrorAsError="True" />
|
<Exec Command="powershell -NonInteractive -ExecutionPolicy ByPass -File ..\postbuild.ps1 -buildDirectory $(OutDir) -buildFilename $(TargetFileName)" LogStandardErrorAsError="True" />
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using System.Text;
|
|||||||
|
|
||||||
namespace ReallifeGamemode.Server.Util
|
namespace ReallifeGamemode.Server.Util
|
||||||
{
|
{
|
||||||
class TaxiContract
|
public class TaxiContract
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
<Reference Include="Bootstrapper">
|
<Reference Include="Bootstrapper">
|
||||||
<HintPath>..\Import\Bootstrapper.dll</HintPath>
|
<HintPath>..\Import\Bootstrapper.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Newtonsoft.Json">
|
||||||
|
<HintPath>..\Import\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user