From fd3b9b9ebcc57cf07c63035a9b359bbcabf4fe16 Mon Sep 17 00:00:00 2001 From: Fabian Fabian Date: Sun, 22 Sep 2019 17:27:48 +0200 Subject: [PATCH] =?UTF-8?q?f=C3=BCr=20siga?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ReallifeGamemode.Client/index.ts | 5 +- ReallifeGamemode.Client/util/checkpoint.ts | 13 ++- ReallifeGamemode.Client/util/drivingschool.ts | 77 ++++++++++++- ReallifeGamemode.Client/util/notification.ts | 6 ++ .../DrivingSchool/DrivingSchool.cs | 101 ++++++++++++++++-- ReallifeGamemode.Server/Job/BusDriverJob.cs | 6 +- ReallifeGamemode.Server/Job/PilotJob.cs | 2 +- .../Util/CheckPointHandle.cs | 16 +-- 8 files changed, 197 insertions(+), 29 deletions(-) create mode 100644 ReallifeGamemode.Client/util/notification.ts diff --git a/ReallifeGamemode.Client/index.ts b/ReallifeGamemode.Client/index.ts index 046996a8..2bca67b4 100644 --- a/ReallifeGamemode.Client/index.ts +++ b/ReallifeGamemode.Client/index.ts @@ -166,4 +166,7 @@ import busRouteList from './Jobs/BusRouteSelect'; busRouteList(globalData); import drivingSchoolHandle from './util/drivingschool'; -drivingSchoolHandle(globalData); \ No newline at end of file +drivingSchoolHandle(globalData); + +import notificationUtil from './util/notification'; +notificationUtil(); \ No newline at end of file diff --git a/ReallifeGamemode.Client/util/checkpoint.ts b/ReallifeGamemode.Client/util/checkpoint.ts index 03d8ffb6..3f53208a 100644 --- a/ReallifeGamemode.Client/util/checkpoint.ts +++ b/ReallifeGamemode.Client/util/checkpoint.ts @@ -11,20 +11,25 @@ export default function checkpointHandle(globalData: GlobalData) { var delay; var delayCounter; var markerID; + var event; + var checkPointsDone = 0; - mp.events.add('setCheckPoint', (position, player, nDelay, nMarkerID) => { + mp.events.add('setCheckPoint', (position, player, checkPointID, nDelay, nMarkerID, nEvent) => { inCheckpoint = false; posCp = position; Player = player; delay = nDelay; markerID = nMarkerID; delayCounter = 0; + checkPointsDone = checkPointID; + event = nEvent; activeCheckpoint = mp.markers.new(markerID, posCp, 3.0, { color: [255, 0, 0, 150], visible: true, dimension: 0 }); + clearInterval(myVar); //mp.events.call("SERVER:Util_setWaypoint", posCp.X, posCp.Z); mp.game.ui.setNewWaypoint(posCp.x, posCp.y); myVar = setInterval(myTimer, 100); @@ -47,6 +52,12 @@ export default function checkpointHandle(globalData: GlobalData) { activeCheckpoint.visible = false; clearInterval(myVar); mp.events.callRemote("playerInCheckpoint"); + if (event != "") { + while (checkPointsDone > 10000) { + + } + mp.events.callRemote(event, checkPointsDone); + } } else { delayCounter += 100; } diff --git a/ReallifeGamemode.Client/util/drivingschool.ts b/ReallifeGamemode.Client/util/drivingschool.ts index b3f18ecb..2a7ace68 100644 --- a/ReallifeGamemode.Client/util/drivingschool.ts +++ b/ReallifeGamemode.Client/util/drivingschool.ts @@ -16,6 +16,13 @@ export default function drivingSchoolHandle(globalData: GlobalData) { var mainMenu: NativeUI.Menu; let send = new UIMenuItem("Pruefung starten", ""); var timer; + var timerCheckpoint; + var timerSet = false; + var Player; + var timeToWait = 0; + var checkPoint; + var counter = 0; + var waitFinished = false; mp.events.add('drivingSchoolMenu', () => { mp.game.ui.setTextComponentFormat('STRING'); @@ -40,18 +47,78 @@ export default function drivingSchoolHandle(globalData: GlobalData) { mp.events.add('waitPlayerEntersVehicle', () => { mp.game.ui.setNewWaypoint(-761.9943, -1321.84); - timer = setInterval(timerFunc, 3000); + timerSet = true; + timer = setInterval(timerPlayerInVehicle, 3000); }); mp.events.add('stopTimer', () => { + timerSet = false; clearInterval(timer); - }); + }); + mp.events.add('waitHere', (player, CP, time) => { + let dist; + waitFinished = false; + timeToWait = time; + Player = player; + checkPoint = CP; + let counter = 0; + clearInterval(timerCheckpoint); + counter = 0; + timerCheckpoint = setInterval(timerWaitHere, 100); + + }); - function timerFunc() { - mp.gui.chat.push("wait"); - mp.events.callRemote('timerCheckVehicle'); + mp.events.add('checkWait', () => { + if (waitFinished == false) { + mp.gui.chat.push("Du hast an der letzten Kreuzung nicht gewartet"); + } + }); + + mp.events.add('lookDirection', (direction, angle1, angle2) => { + let player = mp.players.local; + + let camera = mp.cameras.new("gameplay"); + var dir = camera.getDirection(); + //0.74850505590443884 0.093938655593395233 + if (!(dir.x <= angle1 && dir.x >= angle2)) { + mp.gui.chat.push("Du hast nicht nach " + direction + " geschaut!"); + } + //0.38181596994400024 0.9669561386108398 + }); + + mp.events.add('lookDirectionTesting', (veh) => { + let player = mp.players.local; + let camera = mp.cameras.new("gameplay"); + var dir = camera.getDirection(); + + + mp.gui.chat.push("x: " + veh.rotation.x + " | y: " + veh.rotation.y + " |z: " + veh.rotation.z); + }); + + function timerWaitHere() { + let dist = mp.game.gameplay.getDistanceBetweenCoords(Player.position.x, Player.position.y, 0, checkPoint.x, checkPoint.y, 0, false); + + if (dist <= 2) { + counter += 100; + } else { + counter = 0; + } + + if (counter >= timeToWait) { + mp.gui.chat.push("Gut, fahre nun weiter."); + waitFinished = true; + clearInterval(timerCheckpoint); + counter = 0; + } + + }; + + function timerPlayerInVehicle() { + if (timerSet) { + mp.events.callRemote('timerCheckVehicle'); + } }; function keyPressHandler() { diff --git a/ReallifeGamemode.Client/util/notification.ts b/ReallifeGamemode.Client/util/notification.ts new file mode 100644 index 00000000..719001e6 --- /dev/null +++ b/ReallifeGamemode.Client/util/notification.ts @@ -0,0 +1,6 @@ +export default function notificationUtil() { + mp.events.add("SERVER:Util_sendNotification", (player, text) => { + mp.gui.chat.push("sendnotification"); + player.SendNotification("" + text); + }); +} \ No newline at end of file diff --git a/ReallifeGamemode.Server/DrivingSchool/DrivingSchool.cs b/ReallifeGamemode.Server/DrivingSchool/DrivingSchool.cs index 9557c73c..b810a62f 100644 --- a/ReallifeGamemode.Server/DrivingSchool/DrivingSchool.cs +++ b/ReallifeGamemode.Server/DrivingSchool/DrivingSchool.cs @@ -21,14 +21,14 @@ namespace ReallifeGamemode.Server.DrivingSchool //BEGIN new Vector3(-745.6191, -1285.735, 4.947221), new Vector3(-704.5242, -1246.765, 9.885977), - new Vector3(-669.0187, -1277.192, 10.29253), + new Vector3(-673.0675, -1266.652, 10.29717), new Vector3(-646.1747, -1293.238, 10.28384), new Vector3(-510.7098, -916.9164, 25.10735), new Vector3(-492.6284, -860.5167, 29.89526), + new Vector3(-450.3232, -841.7007, 30.3698), new Vector3(17.09636, -973.2763, 29.01929), new Vector3(76.66012, -999.568, 28.97918), //SLALOM - new Vector3(-14.43704, -1719.955, 28.98133), new Vector3(-12.64976, -1751.287, 28.91913), new Vector3(6.008641, -1767.067, 28.91265), new Vector3(12.80635, -1752.094, 28.91877), @@ -45,8 +45,8 @@ namespace ReallifeGamemode.Server.DrivingSchool new Vector3(111.6519, -1822.466, 26.03703), //SCHROTTPLATZ new Vector3(-394.8713, -1734.21, 19.23653), - new Vector3(-468.9609, -1687.248, 18.56528), - new Vector3(-475.5448, -1670.373, -18.34653), + new Vector3(-459.7604, -1696.029, 18.62012), + new Vector3(-475.5448, -1670.373, 18.34653), new Vector3(-453.5338, -1665.695, 18.64714), new Vector3(-449.6863, -1680.451, 18.66275), new Vector3(-467.9489, -1728.37, 18.27419), @@ -55,7 +55,7 @@ namespace ReallifeGamemode.Server.DrivingSchool new Vector3(-509.998, -1691.828, 18.91303), new Vector3(-526.3292, -1685.291, 18.83323), new Vector3(-551.9138, -1651.865, 18.81676), - new Vector3(-520.2884, -1632.388, 17.41465), + new Vector3(-529.8453, -1626.317, 17.41884), new Vector3(-491.7721, -1648.275, 17.43219), new Vector3(-550.9622, -1662.636, 18.82121), new Vector3(-496.3094, -1736.833, 18.33857), @@ -78,15 +78,13 @@ namespace ReallifeGamemode.Server.DrivingSchool private static void EntityEnterBusinessColShape(ColShape colShape, Client client) { if (client.IsInVehicle || !client.IsLoggedIn()) return; - + client.TriggerEvent("drivingSchoolMenu"); - //client.TriggerEvent("SERVER:Business_ShowMenuHelp"); } private static void EntityExitBusinessColShape(ColShape colShape, Client client) { client.TriggerEvent("removeDrivingSchoolMenu"); - //client.TriggerEvent("SERVER:Business_RemoveHelp", true); } [RemoteEvent("startDrivingSchool")] @@ -106,13 +104,94 @@ namespace ReallifeGamemode.Server.DrivingSchool if (veh == null || veh.DisplayName != "Buffalo") { return; - } else + } + else { ChatService.SendMessage(user, "Gut nun kann die Prüfung losgehen"); user.TriggerEvent("stopTimer"); - CheckPointHandle.StartCheckPointRoute(user, DrivingRoute, 0, 1); + CheckPointHandle.StartCheckPointRoute(user, DrivingRoute, 0, 1, "drivingSchoolEvent"); + } + } + + [RemoteEvent("drivingSchoolEvent")] + public void DrivingSchoolEvent(Client user, int checkpoint) + { + ChatService.Broadcast("CP " + checkpoint); + if (checkpoint == 0 || checkpoint == 4) + { + ChatService.SendMessage(user, "Halte an der Kreuzung kurz an"); + } + else if (checkpoint == 1 || checkpoint == 5) + { + user.TriggerEvent("waitHere", user, DrivingRoute.ElementAt(checkpoint), 2000); + } + else if (checkpoint == 2) + { + user.TriggerEvent("checkWait"); + ChatService.SendMessage(user, "Schaue an der nächsten Kreuzung nach rechts"); + } + else if (checkpoint == 3) + { + //0.74850505590443884 -0.04975615441799164 + Single angle1 = (float)0.7485050; + Single angle2 = (float)-0.0497561; + user.TriggerEvent("lookDirection", "rechts", angle1, angle2); + } + else if (checkpoint == 6) + { + user.TriggerEvent("checkWait"); + } + else if (checkpoint == 7) + { + user.TriggerEvent("checkWait"); + ChatService.SendMessage(user, "Schaue an der nächsten Kreuzung nach links"); } - } + else if (checkpoint == 8) + { + Single angle1 = (float)0.9669561; + Single angle2 = (float)0.3818159; + user.TriggerEvent("lookDirection", "links", angle1, angle2); + } + else if (checkpoint == 9) + { + ChatService.SendMessage(user, "Fahre nun Slalom an den Laternen"); + } + else if (checkpoint == 20) + { + ChatService.SendMessage(user, "Verlasse nun den Parkplatz"); + } + else if (checkpoint == 24) + { + ChatService.SendMessage(user, "Parke gleich seitlich ein"); + } + else if (checkpoint == 25) + { + bool parked = false; + float rotation; + + while (!parked) + { + rotation = user.Vehicle.Rotation.Z; + if (rotation >= 333.913 && rotation <= 354.6108) + { + ChatService.SendMessage(user, "Perfekt!"); + parked = true; + } + System.Threading.Thread.Sleep(100); + } + + + } + } + + [Command("ld", "~m~Benutzung: ~s~/lt")] + public void CmdAdminLt(Client player) + { + Vehicle veh = player.Vehicle; + ChatService.Broadcast("x: " + veh.Rotation.X + " | y: " + veh.Rotation.Y + " | z: " + veh.Rotation.Z); + + //player.TriggerEvent("lookDirectionTesting", veh); + } } } diff --git a/ReallifeGamemode.Server/Job/BusDriverJob.cs b/ReallifeGamemode.Server/Job/BusDriverJob.cs index 8bfc0304..918f3433 100644 --- a/ReallifeGamemode.Server/Job/BusDriverJob.cs +++ b/ReallifeGamemode.Server/Job/BusDriverJob.cs @@ -75,13 +75,13 @@ namespace ReallifeGamemode.Server.Job { if (type == "Kurz 1") { - CheckPointHandle.StartCheckPointRoute(player, Route1, 3000, 1); + CheckPointHandle.StartCheckPointRoute(player, Route1, 3000, 1, ""); } else if (type == "Kurz 2") { - CheckPointHandle.StartCheckPointRoute(player, Route2, 3000, 1); + CheckPointHandle.StartCheckPointRoute(player, Route2, 3000, 1, ""); } else if (type == "Mittel 1") { - CheckPointHandle.StartCheckPointRoute(player, Route3, 3000, 1); + CheckPointHandle.StartCheckPointRoute(player, Route3, 3000, 1, ""); } } diff --git a/ReallifeGamemode.Server/Job/PilotJob.cs b/ReallifeGamemode.Server/Job/PilotJob.cs index e6e8e2a7..2e01bfcf 100644 --- a/ReallifeGamemode.Server/Job/PilotJob.cs +++ b/ReallifeGamemode.Server/Job/PilotJob.cs @@ -28,7 +28,7 @@ namespace ReallifeGamemode.Server.Job private void PilotJob_JobStart(Client player) { - CheckPointHandle.StartCheckPointRoute(player, Route1, 0, 6); + CheckPointHandle.StartCheckPointRoute(player, Route1, 0, 6, ""); } } } diff --git a/ReallifeGamemode.Server/Util/CheckPointHandle.cs b/ReallifeGamemode.Server/Util/CheckPointHandle.cs index f02f513d..ee476e41 100644 --- a/ReallifeGamemode.Server/Util/CheckPointHandle.cs +++ b/ReallifeGamemode.Server/Util/CheckPointHandle.cs @@ -7,10 +7,10 @@ namespace ReallifeGamemode.Server.Util public class CheckPointHandle : Script { public static List listHandle = new List(); - public static void StartCheckPointRoute(Client player, IEnumerable nListCps, int delay, int markerID) + public static void StartCheckPointRoute(Client player, IEnumerable nListCps, int delay, int markerID, string nEvent) { RemovePlayerHandlerFromList(player); - CheckPointListForPlayer playerHandle = new CheckPointListForPlayer(player, nListCps, delay, markerID); + CheckPointListForPlayer playerHandle = new CheckPointListForPlayer(player, nListCps, delay, markerID, nEvent); listHandle.Add(playerHandle); playerHandle.StartRoute(); @@ -39,9 +39,8 @@ namespace ReallifeGamemode.Server.Util { break; } - } + } temp.NextCheckpoint(); - } } @@ -51,20 +50,23 @@ namespace ReallifeGamemode.Server.Util public Client player; public int delay = 0; public int markerID; + public string eventInCheckpoint = ""; int checkPointsDone = 0; - public CheckPointListForPlayer(Client nPlayer, IEnumerable nList, int nDelay, int nMarkerID) + public CheckPointListForPlayer(Client nPlayer, IEnumerable nList, int nDelay, int nMarkerID, string nEvent) { this.player = nPlayer; this.list = nList; this.delay = nDelay; this.markerID = nMarkerID; + this.eventInCheckpoint = nEvent; + this.checkPointsDone = 0; } public void StartRoute() { - player.TriggerEvent("setCheckPoint", this.list.ElementAt(0), player, this.delay, this.markerID); + player.TriggerEvent("setCheckPoint", this.list.ElementAt(0), player, 0, this.delay, this.markerID, this.eventInCheckpoint); } public void NextCheckpoint() { @@ -72,7 +74,7 @@ namespace ReallifeGamemode.Server.Util if (this.list.Count() > checkPointsDone) { Vector3 nextCp = list.ElementAt(checkPointsDone); - this.player.TriggerEvent("setCheckPoint", nextCp, player, this.delay, this.markerID); + this.player.TriggerEvent("setCheckPoint", nextCp, player, this.checkPointsDone, delay, this.markerID, this.eventInCheckpoint); } if (this.list.Count() == checkPointsDone) {