diff --git a/ReallifeGamemode.Client/Jobs/BusRouteSelect.ts b/ReallifeGamemode.Client/Jobs/BusRouteSelect.ts new file mode 100644 index 00000000..c5723a04 --- /dev/null +++ b/ReallifeGamemode.Client/Jobs/BusRouteSelect.ts @@ -0,0 +1,67 @@ +import * as NativeUI from 'NativeUI'; + +const Menu = NativeUI.Menu; +const UIMenuItem = NativeUI.UIMenuItem; +const UIMenuListItem = NativeUI.UIMenuListItem; +const UIMenuCheckboxItem = NativeUI.UIMenuCheckboxItem; +const BadgeStyle = NativeUI.BadgeStyle; +const Point = NativeUI.Point; +const ItemsCollection = NativeUI.ItemsCollection; +const Color = NativeUI.Color; + +let screenRes = mp.game.graphics.getScreenResolution(0, 0); + +let sendItem = new UIMenuItem("Starten", "Route starten"); +sendItem.BackColor = new Color(13, 71, 161); +sendItem.HighlightedBackColor = new Color(25, 118, 210); + +let cancelItem = new UIMenuItem("Abbrechen", ""); +cancelItem.BackColor = new Color(213, 0, 0); +cancelItem.HighlightedBackColor = new Color(229, 57, 53); + + +export default function busRouteList(globalData: GlobalData) { + + var routeMenu: NativeUI.Menu; + var routeTexts; + var routeText; + + mp.events.add('showBusRouteMenu', (listRoutes) => { + if (!globalData.InMenu) { + + globalData.InMenu = true; + routeTexts = JSON.parse(listRoutes); + + routeMenu = new Menu("Bus Job", "", new Point(50, 50), null, null); + routeMenu.AddItem(new UIMenuListItem("Route", "", new ItemsCollection(routeTexts))); + + routeMenu.AddItem(sendItem); + routeMenu.AddItem(cancelItem); + routeMenu.AddItem(cancelItem); + routeMenu.Visible = true; + + routeMenu.ListChange.on((item, index) => { + switch (item.Text) { + case "Route": + routeText = String(item.SelectedItem.DisplayText); + break; + } + }); + + routeMenu.ItemSelect.on((item) => { + if (item.Text === "Starten") { + mp.events.callRemote("startBusRoute", routeText); + routeMenu.Close(); + globalData.InMenu = false; + } else if (item.Text === "Abbrechen") { + routeMenu.Close(); + globalData.InMenu = false; + } + }); + + routeMenu.MenuClose.on(() => { + globalData.InMenu = false; + }); + } + }); +} \ No newline at end of file diff --git a/ReallifeGamemode.Client/index.ts b/ReallifeGamemode.Client/index.ts index 97d076e9..faecff02 100644 --- a/ReallifeGamemode.Client/index.ts +++ b/ReallifeGamemode.Client/index.ts @@ -160,4 +160,7 @@ import reportList from './Player/reportmenu'; reportList(globalData); import checkpointHandle from './util/checkpoint'; -checkpointHandle(globalData); \ No newline at end of file +checkpointHandle(globalData); + +import busRouteList from './Jobs/BusRouteSelect'; +busRouteList(globalData); \ No newline at end of file diff --git a/ReallifeGamemode.Server/Job/BusDriverJob.cs b/ReallifeGamemode.Server/Job/BusDriverJob.cs index 4c76e3e1..334e6df9 100644 --- a/ReallifeGamemode.Server/Job/BusDriverJob.cs +++ b/ReallifeGamemode.Server/Job/BusDriverJob.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Text; using GTANetworkAPI; using ReallifeGamemode.Server.Util; +using Newtonsoft.Json; namespace ReallifeGamemode.Server.Job { @@ -14,7 +15,9 @@ namespace ReallifeGamemode.Server.Job public override bool NeedVehicleToStart => true; - private readonly IReadOnlyCollection list = new List + public String routeText; + + private readonly IReadOnlyCollection Route1 = new List { new Vector3(-105.5951, -1684.548, 29.23948), new Vector3(-1056.246, -2552.576, 13.66063), @@ -25,6 +28,17 @@ namespace ReallifeGamemode.Server.Job new Vector3(218.1398, -850.9549, 30.16619) }.AsReadOnly(); + private readonly IReadOnlyCollection Route2 = new List + { + new Vector3(403.4488, -786.5514, 29.2046), + new Vector3(787.6898, -1364.566, 26.41318), + new Vector3(942.0541, -1447.974, 31.14204), + new Vector3(866.8322, -997.5225, 30.48207), + new Vector3(785.4254, -781.3905, 26.33277), + new Vector3(351.5793, -1064.582, 29.40059), + new Vector3(235.0964, -857.1152, 29.74256), + }.AsReadOnly(); + public BusDriverJob() { JobStart += BusDriverJob_JobStart; @@ -32,7 +46,24 @@ namespace ReallifeGamemode.Server.Job private void BusDriverJob_JobStart(Client player) { - CheckPointHandle.StartCheckPointRoute(player, list); + List listRouteTexts = new List(); + listRouteTexts.Add("Kurz 1"); + listRouteTexts.Add("Kurz 2"); + + player.TriggerEvent("showBusRouteMenu", JsonConvert.SerializeObject(listRouteTexts)); + } + + [RemoteEvent("startBusRoute")] + public void StartBusRoute(Client player, string type) + { + if (type == "Kurz 1") + { + CheckPointHandle.StartCheckPointRoute(player, Route1); + } else if (type == "Kurz 2") + { + CheckPointHandle.StartCheckPointRoute(player, Route2); + } + } } } diff --git a/ReallifeGamemode.Server/Util/CheckPointHandle.cs b/ReallifeGamemode.Server/Util/CheckPointHandle.cs index e6f4d358..df55a729 100644 --- a/ReallifeGamemode.Server/Util/CheckPointHandle.cs +++ b/ReallifeGamemode.Server/Util/CheckPointHandle.cs @@ -47,10 +47,7 @@ namespace ReallifeGamemode.Server.Util break; } } - temp.NextCheckpoint(); - - ChatService.Broadcast("neuer cp"); } } @@ -80,7 +77,6 @@ namespace ReallifeGamemode.Server.Util 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); } if (this.list.Count() == checkPointsDone)