From b3d3d4550db53cd7529d1f9e2aa4738bdda37188 Mon Sep 17 00:00:00 2001 From: Fabian Fabian Date: Mon, 16 Sep 2019 15:05:23 +0200 Subject: [PATCH] added pilot job --- .../Jobs/BusRouteSelect.ts | 1 + ReallifeGamemode.Client/util/checkpoint.ts | 30 ++++++++++++++----- ReallifeGamemode.Server/Job/BusDriverJob.cs | 4 +-- ReallifeGamemode.Server/Job/PilotJob.cs | 24 +++++++++++++++ .../Util/CheckPointHandle.cs | 14 +++++---- 5 files changed, 59 insertions(+), 14 deletions(-) diff --git a/ReallifeGamemode.Client/Jobs/BusRouteSelect.ts b/ReallifeGamemode.Client/Jobs/BusRouteSelect.ts index 027f84bd..dd636070 100644 --- a/ReallifeGamemode.Client/Jobs/BusRouteSelect.ts +++ b/ReallifeGamemode.Client/Jobs/BusRouteSelect.ts @@ -38,6 +38,7 @@ export default function busRouteList(globalData: GlobalData) { routeMenu.AddItem(sendItem); routeMenu.AddItem(cancelItem); routeMenu.Visible = true; + routeText = "Kurz 1"; routeMenu.ListChange.on((item, index) => { switch (item.Text) { diff --git a/ReallifeGamemode.Client/util/checkpoint.ts b/ReallifeGamemode.Client/util/checkpoint.ts index 454b0746..7e41cd1b 100644 --- a/ReallifeGamemode.Client/util/checkpoint.ts +++ b/ReallifeGamemode.Client/util/checkpoint.ts @@ -8,12 +8,18 @@ export default function checkpointHandle(globalData: GlobalData) { var Player; var activeCheckpoint; var inCheckpoint = false; + var delay; + var delayCounter; + var markerID; - mp.events.add('setCheckPoint', (position, player) => { + mp.events.add('setCheckPoint', (position, player, nDelay, nMarkerID) => { inCheckpoint = false; posCp = position; Player = player; - activeCheckpoint = mp.markers.new(1, posCp, 3.0, { + delay = nDelay; + markerID = nMarkerID; + delayCounter = 0; + activeCheckpoint = mp.markers.new(markerID, posCp, 3.0, { color: [255, 0, 0, 150], visible: true, dimension: 0 @@ -26,15 +32,25 @@ export default function checkpointHandle(globalData: GlobalData) { function myTimer() { let dist = mp.game.gameplay.getDistanceBetweenCoords(Player.position.x, Player.position.y, 0, posCp.x, posCp.y, 0, false); - - if (dist <= 2 && !inCheckpoint) { + //mp.gui.chat.push("delay: " + delay + " | delayCounter: " + delayCounter); + if (dist <= 2) { mp.game.audio.playSoundFrontend(1, "Beep_Red", "DLC_HEIST_HACKING_SNAKE_SOUNDS", true); + + if (!inCheckpoint) { + mp.gui.chat.push("Warte nun " + delay / 1000 + " Sekunden"); + } inCheckpoint = true; - activeCheckpoint.visible = false; - clearInterval(myVar); - mp.events.callRemote("playerInCheckpoint"); + + if (delayCounter >= delay) { + activeCheckpoint.visible = false; + clearInterval(myVar); + mp.events.callRemote("playerInCheckpoint"); + } else { + delayCounter += 100; + } } else if (dist > 2) { inCheckpoint = false; + delayCounter = 0; } } } \ No newline at end of file diff --git a/ReallifeGamemode.Server/Job/BusDriverJob.cs b/ReallifeGamemode.Server/Job/BusDriverJob.cs index 5eb94b7e..34bfc09b 100644 --- a/ReallifeGamemode.Server/Job/BusDriverJob.cs +++ b/ReallifeGamemode.Server/Job/BusDriverJob.cs @@ -60,10 +60,10 @@ namespace ReallifeGamemode.Server.Job { if (type == "Kurz 1") { - CheckPointHandle.StartCheckPointRoute(player, Route1); + CheckPointHandle.StartCheckPointRoute(player, Route1, 3000, 1); } else if (type == "Kurz 2") { - CheckPointHandle.StartCheckPointRoute(player, Route2); + CheckPointHandle.StartCheckPointRoute(player, Route2, 3000, 1); } } diff --git a/ReallifeGamemode.Server/Job/PilotJob.cs b/ReallifeGamemode.Server/Job/PilotJob.cs index b6adaa41..c6a903ef 100644 --- a/ReallifeGamemode.Server/Job/PilotJob.cs +++ b/ReallifeGamemode.Server/Job/PilotJob.cs @@ -1,6 +1,11 @@ using System; using System.Collections.Generic; using System.Text; +using GTANetworkAPI; +using ReallifeGamemode.Server.Util; +using Newtonsoft.Json; +using GTANetworkAPI; +using ReallifeGamemode.Server.Services; namespace ReallifeGamemode.Server.Job { @@ -11,5 +16,24 @@ namespace ReallifeGamemode.Server.Job public override string Name => "Pilot"; public override bool NeedVehicleToStart => true; + + private readonly IReadOnlyCollection Route1 = new List + { + new Vector3(-1059.862, -3100.353, 13.94444), + new Vector3(1690.651, 3246.769, 40.87084), + new Vector3(-2376.512, 3063.054, 32.82592), + new Vector3(2056.1, 4774.556, 4106039), + new Vector3(-1059.862, -3100.353, 13.94444), + }.AsReadOnly(); + + public PilotJob() + { + JobStart += PilotJob_JobStart; + } + + private void PilotJob_JobStart(Client player) + { + CheckPointHandle.StartCheckPointRoute(player, Route1, 0, 6); + } } } diff --git a/ReallifeGamemode.Server/Util/CheckPointHandle.cs b/ReallifeGamemode.Server/Util/CheckPointHandle.cs index df55a729..b77eda7b 100644 --- a/ReallifeGamemode.Server/Util/CheckPointHandle.cs +++ b/ReallifeGamemode.Server/Util/CheckPointHandle.cs @@ -15,9 +15,9 @@ namespace ReallifeGamemode.Server.Util public class CheckPointHandle : Script { public static List listHandle = new List(); - public static void StartCheckPointRoute(Client player, IEnumerable nListCps) + public static void StartCheckPointRoute(Client player, IEnumerable nListCps, int delay, int markerID) { - CheckPointListForPlayer playerHandle = new CheckPointListForPlayer(player, nListCps); + CheckPointListForPlayer playerHandle = new CheckPointListForPlayer(player, nListCps, delay, markerID); listHandle.Add(playerHandle); playerHandle.StartRoute(); @@ -55,21 +55,25 @@ namespace ReallifeGamemode.Server.Util { public IEnumerable list = new List(); public Client player; + public int delay = 0; + public int markerID; Vector3 checkPoint; bool done; int checkPointsDone = 0; - public CheckPointListForPlayer(Client nPlayer, IEnumerable nList) + public CheckPointListForPlayer(Client nPlayer, IEnumerable nList, int nDelay, int nMarkerID) { this.player = nPlayer; this.list = nList; + this.delay = nDelay; + this.markerID = nMarkerID; } public void StartRoute() { - player.TriggerEvent("setCheckPoint", this.list.ElementAt(0), player); + player.TriggerEvent("setCheckPoint", this.list.ElementAt(0), player, this.delay, this.markerID); } public void NextCheckpoint() { @@ -77,7 +81,7 @@ namespace ReallifeGamemode.Server.Util if (this.list.Count() > checkPointsDone) { Vector3 nextCp = list.ElementAt(checkPointsDone); - this.player.TriggerEvent("setCheckPoint", nextCp, player); + this.player.TriggerEvent("setCheckPoint", nextCp, player, this.delay, this.markerID); } if (this.list.Count() == checkPointsDone) {