From 5ea2487b293eb1ba266a39b962ab53447fc9c2e2 Mon Sep 17 00:00:00 2001 From: Fabian Fabian Date: Thu, 12 Sep 2019 18:20:18 +0200 Subject: [PATCH] renewed and improved busdriver job system, paaqo is not amused --- ReallifeGamemode.Client/util/checkpoint.ts | 8 ++- ReallifeGamemode.Server/Job/BusDriverJob.cs | 2 + ReallifeGamemode.Server/Job/JobBase.cs | 12 ++++ .../Util/CheckPointHandle.cs | 66 +++++++++++++++---- 4 files changed, 74 insertions(+), 14 deletions(-) diff --git a/ReallifeGamemode.Client/util/checkpoint.ts b/ReallifeGamemode.Client/util/checkpoint.ts index e9a28c70..46da9539 100644 --- a/ReallifeGamemode.Client/util/checkpoint.ts +++ b/ReallifeGamemode.Client/util/checkpoint.ts @@ -10,7 +10,8 @@ export default function checkpointHandle(globalData: GlobalData) { var inCheckpoint = false; mp.events.add('setCheckPoint', (position, player) => { - mp.gui.chat.push("exec"); + mp.gui.chat.push("jaha"); + inCheckpoint = false; posCp = position; Player = player; activeCheckpoint = mp.markers.new(1, posCp, 3.0, { @@ -19,6 +20,8 @@ export default function checkpointHandle(globalData: GlobalData) { dimension: 0 }); + //mp.events.call("SERVER:Util_setWaypoint", posCp.X, posCp.Z); + mp.game.ui.setNewWaypoint(posCp.x, posCp.y); myVar = setInterval(myTimer, 100); }); @@ -26,7 +29,10 @@ export default function checkpointHandle(globalData: GlobalData) { let dist = mp.game.gameplay.getDistanceBetweenCoords(Player.position.x, Player.position.y, 0, posCp.x, posCp.y, 0, false); if (dist <= 2 && !inCheckpoint) { + mp.game.audio.playSoundFrontend(1, "Beep_Red", "DLC_HEIST_HACKING_SNAKE_SOUNDS", true); inCheckpoint = true; + activeCheckpoint.visible = false; + clearInterval(myVar); mp.events.callRemote("playerInCheckpoint"); } else if (dist > 2) { inCheckpoint = false; diff --git a/ReallifeGamemode.Server/Job/BusDriverJob.cs b/ReallifeGamemode.Server/Job/BusDriverJob.cs index 5987d364..1f3536f6 100644 --- a/ReallifeGamemode.Server/Job/BusDriverJob.cs +++ b/ReallifeGamemode.Server/Job/BusDriverJob.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; using System.Text; +using GTANetworkAPI; +using ReallifeGamemode.Server.Util; namespace ReallifeGamemode.Server.Job { diff --git a/ReallifeGamemode.Server/Job/JobBase.cs b/ReallifeGamemode.Server/Job/JobBase.cs index 16376fb1..34e87585 100644 --- a/ReallifeGamemode.Server/Job/JobBase.cs +++ b/ReallifeGamemode.Server/Job/JobBase.cs @@ -8,6 +8,8 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using ReallifeGamemode.Server.Util; +using System.Collections; namespace ReallifeGamemode.Server.Job { @@ -35,6 +37,16 @@ namespace ReallifeGamemode.Server.Job ChatService.SendMessage(player, $"~y~[JOB]~s~ Du hast deinen Job ~o~{this.Name}~s~ gestartet."); JobStart?.Invoke(player); + + List list = new List(); + list.Add(new Vector3(-105.5951, -1684.548, 29.23948)); + list.Add(new Vector3(-1056.246, -2552.576, 13.66063)); + list.Add(new Vector3(200.3088, -1978.828, 19.3329)); + list.Add(new Vector3(358.6138, -1785.821, 28.92113)); + list.Add(new Vector3(281.8594, -1462.503, 29.13148)); + list.Add(new Vector3(77.72239, -1212.086, 29.12294)); + list.Add(new Vector3(218.1398, -850.9549, 30.16619)); + CheckPointHandle.startCheckPointRoute(player, list); } public void StopJob(Client player, bool quit = false) diff --git a/ReallifeGamemode.Server/Util/CheckPointHandle.cs b/ReallifeGamemode.Server/Util/CheckPointHandle.cs index 9b1141b9..f734f275 100644 --- a/ReallifeGamemode.Server/Util/CheckPointHandle.cs +++ b/ReallifeGamemode.Server/Util/CheckPointHandle.cs @@ -8,28 +8,68 @@ using ReallifeGamemode.Server.Models; using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Util; using GTANetworkAPI; - +using System.Collections; +using System.Linq; namespace ReallifeGamemode.Server.Util { - class CheckPointHandle : Script + public class CheckPointHandle : Script { - [Command("cp", "~m~Benutzung: ~s~/cp")] - public void CmdCp(Client player) + public static List listHandle = new List(); + public static void startCheckPointRoute(Client player, List nListCps) { - if (!player.IsLoggedIn()) return; + checkPointListForPlayer playerHandle = new checkPointListForPlayer(player, nListCps); + listHandle.Add(playerHandle); - Vector3 cp = player.Position; - - cp.X += 10; - player.TriggerEvent("setCheckPoint", cp, player); + playerHandle.startRoute(); } [RemoteEvent("playerInCheckpoint")] - public void enteredCheckpoints(Client user) + public void playerInCheckpoint(Client user) { - ChatService.SendMessage(user, "ja"); - Vector3 newCp = new Vector3(400, 680, 29); - user.TriggerEvent("setCheckpoint", newCp, user); + ChatService.Broadcast("neuer cp"); + checkPointListForPlayer temp = null; + for (int a = 0; a < listHandle.Count; a++) + { + temp = listHandle[a]; + if (temp.player == user) + { + break; + } + } + + temp.nextCheckpoint(); + + } + } + public class checkPointListForPlayer + { + public List list = new List(); + public Client player; + + Vector3 checkPoint; + Boolean done; + int checkPointsDone = 0; + + public checkPointListForPlayer(Client nPlayer, List nList) + { + this.player = nPlayer; + this.list = nList; + } + + public void startRoute() + { + player.TriggerEvent("setCheckPoint", this.list.ElementAt(0), player); + } + public void nextCheckpoint() + { + this.checkPointsDone++; + if (this.list.Count > checkPointsDone) + { + Vector3 nextCp = list.ElementAt(checkPointsDone); + ChatService.SendMessage(this.player, "cp set at " + nextCp.ToString()); + this.player.TriggerEvent("setCheckPoint", nextCp, player); + } + } } }