From e62ca95f4d02a3614825aafc5f13ec7d82c31051 Mon Sep 17 00:00:00 2001 From: Fabian Fabian Date: Tue, 17 Sep 2019 21:41:06 +0200 Subject: [PATCH] added drivingschool point + checkpoints for route --- ReallifeGamemode.Client/index.ts | 5 +- ReallifeGamemode.Client/util/drivingschool.ts | 63 +++++++++ .../DrivingSchool/DrivingSchool.cs | 120 ++++++++++++++++++ ReallifeGamemode.Server/Main.cs | 2 + .../Util/CheckPointHandle.cs | 1 + 5 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 ReallifeGamemode.Client/util/drivingschool.ts create mode 100644 ReallifeGamemode.Server/DrivingSchool/DrivingSchool.cs diff --git a/ReallifeGamemode.Client/index.ts b/ReallifeGamemode.Client/index.ts index faecff02..046996a8 100644 --- a/ReallifeGamemode.Client/index.ts +++ b/ReallifeGamemode.Client/index.ts @@ -163,4 +163,7 @@ import checkpointHandle from './util/checkpoint'; checkpointHandle(globalData); import busRouteList from './Jobs/BusRouteSelect'; -busRouteList(globalData); \ No newline at end of file +busRouteList(globalData); + +import drivingSchoolHandle from './util/drivingschool'; +drivingSchoolHandle(globalData); \ No newline at end of file diff --git a/ReallifeGamemode.Client/util/drivingschool.ts b/ReallifeGamemode.Client/util/drivingschool.ts new file mode 100644 index 00000000..b3f18ecb --- /dev/null +++ b/ReallifeGamemode.Client/util/drivingschool.ts @@ -0,0 +1,63 @@ +import * as NativeUI from 'NativeUI'; +const Menu = NativeUI.Menu; +const UIMenuItem = NativeUI.UIMenuItem; +const UIMenuListItem = NativeUI.UIMenuListItem; +const UIMenuCheckboxItem = NativeUI.UIMenuCheckboxItem; +const UIMenuSliderItem = NativeUI.UIMenuSliderItem; +const BadgeStyle = NativeUI.BadgeStyle; +const Point = NativeUI.Point; +const ItemsCollection = NativeUI.ItemsCollection; +const Color = NativeUI.Color; +const ListItem = NativeUI.ListItem; + +export default function drivingSchoolHandle(globalData: GlobalData) { + + var keyBound = false; + var mainMenu: NativeUI.Menu; + let send = new UIMenuItem("Pruefung starten", ""); + var timer; + + mp.events.add('drivingSchoolMenu', () => { + mp.game.ui.setTextComponentFormat('STRING'); + mp.game.ui.addTextComponentSubstringPlayerName('Drücke ~INPUT_CONTEXT~, um das Fahrschulmenü zu öffnen'); + mp.game.ui.displayHelpTextFromStringLabel(0, true, true, -1); + + mp.keys.bind(0x45, false, keyPressHandler); + keyBound = true; + }); + + mp.events.add('removeDrivingSchoolMenu', (unbind) => { + mp.game.ui.clearHelp(true); + mp.gui.chat.show(true); + + if (keyBound && unbind) { + if (mainMenu) mainMenu.Close(); + + mp.keys.unbind(0x45, false, keyPressHandler); + keyBound = false; + } + }); + + mp.events.add('waitPlayerEntersVehicle', () => { + mp.game.ui.setNewWaypoint(-761.9943, -1321.84); + timer = setInterval(timerFunc, 3000); + }); + + + mp.events.add('stopTimer', () => { + clearInterval(timer); + }); + + + function timerFunc() { + mp.gui.chat.push("wait"); + mp.events.callRemote('timerCheckVehicle'); + }; + + function keyPressHandler() { + if (globalData.InChat || globalData.InInput || globalData.InMenu) return; + + mp.events.call('removeDrivingSchoolMenu', false); + mp.events.callRemote('startDrivingSchool'); + } +} \ No newline at end of file diff --git a/ReallifeGamemode.Server/DrivingSchool/DrivingSchool.cs b/ReallifeGamemode.Server/DrivingSchool/DrivingSchool.cs new file mode 100644 index 00000000..d17bbd19 --- /dev/null +++ b/ReallifeGamemode.Server/DrivingSchool/DrivingSchool.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Text; +using ReallifeGamemode.Server.Entities; +using ReallifeGamemode.Server.Extensions; +using ReallifeGamemode.Server.Models; +using ReallifeGamemode.Server.Util; +using ReallifeGamemode.Server.Services; +using System.Linq; +using GTANetworkAPI; + +namespace ReallifeGamemode.Server.DrivingSchool +{ + class DrivingSchool : Script + { + private static TextLabel informationLabel; + private static Marker marker; + private static ColShape _colShape; + public static Vector3 Position { get; } + + private readonly IReadOnlyCollection DrivingRoute = new List + { + //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(-646.1747, -1293.238, 10.28384), + new Vector3(-510.7098, -916.9164, 25.10735), + new Vector3(-492.6284, -860.5167, 29.89526), + 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), + new Vector3(26.71735, -1747.96, 28.92006), + new Vector3(28.67053, -1733.492, 28.91953), + new Vector3(42.68731, -1728.767, 28.92002), + new Vector3(44.33229, -1714.426, 28.9193), + new Vector3(37.25899, -1723.924, 28.92041), + new Vector3(34.591, -1738.211, 28.92125), + new Vector3(21.28996, -1742.563, 28.91987), + new Vector3(18.46534, -1756.87, 28.92011), + new Vector3(4.841759, -1761.316, 28.91519), + new Vector3(44.69115, -1805.247, 25.07369), + 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(-453.5338, -1665.695, 18.64714), + new Vector3(-449.6863, -1680.451, 18.66275), + new Vector3(-467.9489, -1728.37, 18.27419), + new Vector3(-520.4453, -1703.146, 18.80065), + new Vector3(-522.3558, -1680.122, 18.88261), + 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(-491.7721, -1648.275, 17.43219), + new Vector3(-550.9622, -1662.636, 18.82121), + new Vector3(-496.3094, -1736.833, 18.33857), + new Vector3(-417.4822, -1712.987, 19.10845), + //ENDE + new Vector3(-498.1252, -1879.154, 17.22348), + new Vector3(-754.5391, -1300.816, 4.617907) + }.AsReadOnly(); + + public static void Setup() + { + informationLabel = NAPI.TextLabel.CreateTextLabel("Fahrschule", new Vector3(-815.8334, -1346.405, 5.150263), 20.0f, 1.3f, 0, new Color(255, 255, 255)); + marker = NAPI.Marker.CreateMarker(434, new Vector3(-815.8334, -1346.405, 5.150263), new Vector3(), new Vector3(), 1f, new Color(255, 255, 255)); + + _colShape = NAPI.ColShape.CreateSphereColShape(new Vector3(-815.8334, -1346.405, 5.150263), 3f); + _colShape.OnEntityEnterColShape += EntityEnterBusinessColShape; + _colShape.OnEntityExitColShape += EntityExitBusinessColShape; + } + + 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")] + public void StartDrivingSchool(Client user) + { + ChatService.SendMessage(user, "Du hast die Führerscheinprüfung gestartet."); + ChatService.SendMessage(user, "Steige nun in eines der Fahrschulautos"); + + user.TriggerEvent("waitPlayerEntersVehicle"); + } + + [RemoteEvent("timerCheckVehicle")] + public void TimerCheckVehicle(Client user) + { + Vehicle veh = user.Vehicle; + + if (veh == null || veh.DisplayName != "Buffalo") + { + return; + } else + { + ChatService.SendMessage(user, "Gut nun kann die Prüfung losgehen"); + user.TriggerEvent("stopTimer"); + + CheckPointHandle.StartCheckPointRoute(user, DrivingRoute, 0, 1); + } + } + } +} diff --git a/ReallifeGamemode.Server/Main.cs b/ReallifeGamemode.Server/Main.cs index 008914df..2f16eceb 100644 --- a/ReallifeGamemode.Server/Main.cs +++ b/ReallifeGamemode.Server/Main.cs @@ -6,6 +6,7 @@ using ReallifeGamemode.Server.Finance; using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Wanted; +using ReallifeGamemode.Server.DrivingSchool; /** * @overview Life of German Reallife - Main Class (Main.cs) @@ -58,6 +59,7 @@ namespace ReallifeGamemode.Server CityHallManager.LoadCityHall(); JobManager.LoadJobs(); HouseManager.LoadHouses(); + DrivingSchool.DrivingSchool.Setup(); TempBlip tempBlip = new TempBlip() diff --git a/ReallifeGamemode.Server/Util/CheckPointHandle.cs b/ReallifeGamemode.Server/Util/CheckPointHandle.cs index 8c9e7fc8..f02f513d 100644 --- a/ReallifeGamemode.Server/Util/CheckPointHandle.cs +++ b/ReallifeGamemode.Server/Util/CheckPointHandle.cs @@ -41,6 +41,7 @@ namespace ReallifeGamemode.Server.Util } } temp.NextCheckpoint(); + } }