From 511b05a5e659c0daa9f9341cd6f2275a4538d534 Mon Sep 17 00:00:00 2001 From: Lukas Moungos Date: Fri, 26 Jul 2019 00:13:27 +0200 Subject: [PATCH] [+] Elevator System. + FIB, LSED, Ballas & GS duty / weapon rack --- .../Interaction/elevator.ts | 71 +++++++++++++++++++ ReallifeGamemode.Client/Player/dutycloth.ts | 2 +- ReallifeGamemode.Client/index.ts | 3 + ReallifeGamemode.Server/Events/Key.cs | 14 ++++ .../Events/UpdateCharacterCloth.cs | 4 +- .../Events/UpdateCharacterElevator.cs | 22 ++++++ .../Managers/PositionManager.cs | 52 +++++++++++++- 7 files changed, 163 insertions(+), 5 deletions(-) create mode 100644 ReallifeGamemode.Client/Interaction/elevator.ts create mode 100644 ReallifeGamemode.Server/Events/UpdateCharacterElevator.cs diff --git a/ReallifeGamemode.Client/Interaction/elevator.ts b/ReallifeGamemode.Client/Interaction/elevator.ts new file mode 100644 index 00000000..90f3009f --- /dev/null +++ b/ReallifeGamemode.Client/Interaction/elevator.ts @@ -0,0 +1,71 @@ +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 saveItem = new UIMenuItem("Bestätigen", ""); +saveItem.BackColor = new Color(13, 71, 161); +saveItem.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 elevatorList(globalData: GlobalData) { + + var elevatorMenu: NativeUI.Menu; + + var stages; + + var stage = ""; + + + //Weapon Menu + + mp.events.add('showElevatorMenu', (stagesArr) => { + if (!globalData.InMenu) { + + globalData.InMenu = true; + + stages = JSON.parse(stagesArr); + + elevatorMenu = new Menu("Aufzug", "", new Point(50, 50), null, null); + + elevatorMenu.AddItem(new UIMenuListItem("Stock", "", new ItemsCollection(stages))); + + elevatorMenu.AddItem(saveItem); + elevatorMenu.AddItem(cancelItem); + elevatorMenu.Visible = true; + + elevatorMenu.ListChange.on((item, index) => { + switch (item.Text) { + case "Stock": + stage = String(item.SelectedItem.DisplayText); + break; + } + }); + + elevatorMenu.ItemSelect.on((item) => { + if (item.Text === "Bestätigen") { + mp.events.callRemote("sendClientToStage", stage); + elevatorMenu.Close(); + globalData.InMenu = false; + } else if (item.Text === "Abbrechen") { + elevatorMenu.Close(); + globalData.InMenu = false; + } + }); + + elevatorMenu.MenuClose.on(() => { + globalData.InMenu = false; + }); + } + }); +} \ No newline at end of file diff --git a/ReallifeGamemode.Client/Player/dutycloth.ts b/ReallifeGamemode.Client/Player/dutycloth.ts index 258794b0..99bcbf29 100644 --- a/ReallifeGamemode.Client/Player/dutycloth.ts +++ b/ReallifeGamemode.Client/Player/dutycloth.ts @@ -52,7 +52,7 @@ export default function dutyCloth(globalData: GlobalData) { dutyMenu = new Menu("Dienstkleidung", "Stelle deine Dienstkleidung zusammen", new Point(50, 50), null, null); - dutyMenu.AddItem(new UIMenuListItem("Hut", "", new ItemsCollection(hats))); + dutyMenu.AddItem(new UIMenuListItem("Accessoire", "", new ItemsCollection(hats))); dutyMenu.AddItem(new UIMenuListItem("Top", "", new ItemsCollection(tops))); dutyMenu.AddItem(new UIMenuListItem("Hose", "", new ItemsCollection(legs))); dutyMenu.AddItem(new UIMenuListItem("Schuhe", "", new ItemsCollection(shoes))); diff --git a/ReallifeGamemode.Client/index.ts b/ReallifeGamemode.Client/index.ts index 2d775249..97d698ba 100644 --- a/ReallifeGamemode.Client/index.ts +++ b/ReallifeGamemode.Client/index.ts @@ -91,6 +91,9 @@ interiors(globalData); import factionInteraction from './Interaction/factioninteraction'; factionInteraction(globalData); +import elevatorList from './Interaction/elevator'; +elevatorList(globalData); + import worldInteraction from './Interaction/worldinteraction'; worldInteraction(); diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index ca5a9f96..c81f02c3 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -134,6 +134,7 @@ namespace ReallifeGamemode.Server.Events DutyPoint nearestDuty = PositionManager.DutyPoints.Find(d => d.Position.DistanceTo(player.Position) <= 1.5 && d.FactionId == user.FactionId); WeaponPoint nearestWeapon = PositionManager.WeaponPoints.Find(w => w.Position.DistanceTo(player.Position) <= 1.5 && w.FactionId == user.FactionId); JailReleasePoint nearestJailReleasePoint = PositionManager.JailReleasePoints.Find(j => j.Position.DistanceTo(player.Position) <= 1.5 && (user.FactionId == 1 || user.FactionId == 3) && user.GetData("duty")); + ElevatorPoint nearestElevatorPoint = PositionManager.ElevatorPoints.Find(e => e.Position.DistanceTo(player.Position) <= 1.5 && (user.FactionId == 1 || user.FactionId == 3)); if (nearestDuty != null)// Duty Point { var nameTagColor = new Color(0, 0, 0); @@ -173,6 +174,7 @@ namespace ReallifeGamemode.Server.Events case 3: nameTagColor = new Color(173, 0, 118); player.SetSharedData("blipColor", 83); + player.SetAccessories(2, 2, 0); break; } player.NametagColor = nameTagColor; @@ -266,6 +268,18 @@ namespace ReallifeGamemode.Server.Events } player.TriggerEvent("showJailMenu", JsonConvert.SerializeObject(criminals.ToArray())); } + if (nearestElevatorPoint != null) + { + List stages = new List(); + foreach(var e in PositionManager.ElevatorPoints) + { + if(e.Position.DistanceTo2D(player.Position) <= 25 && e.Position.DistanceTo(player.Position) > 1.5) + { + stages.Add(e.Stage); + } + } + player.TriggerEvent("showElevatorMenu", JsonConvert.SerializeObject(stages.ToArray())); + } } } diff --git a/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs b/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs index b5d61072..eb40581e 100644 --- a/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs +++ b/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs @@ -20,6 +20,8 @@ namespace ReallifeGamemode.Server.Events else { player.ClearAccessory(0); + player.ClearAccessory(1); + player.ClearAccessory(2); } } @@ -151,4 +153,4 @@ namespace ReallifeGamemode.Server.Events } } } -} \ No newline at end of file +} diff --git a/ReallifeGamemode.Server/Events/UpdateCharacterElevator.cs b/ReallifeGamemode.Server/Events/UpdateCharacterElevator.cs new file mode 100644 index 00000000..87d7cdec --- /dev/null +++ b/ReallifeGamemode.Server/Events/UpdateCharacterElevator.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; +using GTANetworkAPI; +using ReallifeGamemode.Server.Managers; + + +namespace ReallifeGamemode.Server.Events +{ + public class UpdateCharacterElevator : Script + { + [RemoteEvent("sendClientToStage")] + public void SaveWeaponSelection(Client client, string stage) + { + ElevatorPoint elevator = PositionManager.ElevatorPoints.Find(e => e.Stage == stage); + if(elevator != null) + { + client.Position = elevator.Position; + } + } + } +} diff --git a/ReallifeGamemode.Server/Managers/PositionManager.cs b/ReallifeGamemode.Server/Managers/PositionManager.cs index 2c52d2d6..4f403a45 100644 --- a/ReallifeGamemode.Server/Managers/PositionManager.cs +++ b/ReallifeGamemode.Server/Managers/PositionManager.cs @@ -17,6 +17,9 @@ namespace ReallifeGamemode.Server.Managers public static List JailReleasePoints = new List(); public static List JailReleaseColShapes = new List(); + public static List ElevatorPoints = new List(); + public static List ElevatorColShapes = new List(); + [ServerEvent(Event.ResourceStart)] public void OnResourceStart() { @@ -57,7 +60,8 @@ namespace ReallifeGamemode.Server.Managers }; WeaponPoint weaponPointFIB = new WeaponPoint() { - Position = new Vector3(119.6835, -729.3273, 242.1519), + //Position = new Vector3(119.6835, -729.3273, 242.1519), old + Position = new Vector3(143.5561,-762.7424,242.152), FactionId = 3 }; WeaponPoint weaponPointBallas = new WeaponPoint() @@ -83,21 +87,57 @@ namespace ReallifeGamemode.Server.Managers NAPI.TextLabel.CreateTextLabel("Waffenspind - Dr\u00fccke ~y~E", w.Position, 7, 1, 0, new Color(255, 255, 255), false, 0); } #endregion - #region JailReleasePoint + #region JailReleasePoints JailReleasePoint jailPointLSPD = new JailReleasePoint() { Position = new Vector3(459.5327, -988.8435, 24.91487) }; + JailReleasePoint jailPointFIB = new JailReleasePoint() + { + Position = new Vector3(119.6362,-727.6199,242.152) + }; JailReleasePoints.Add(jailPointLSPD); + JailReleasePoints.Add(jailPointFIB); - foreach(JailReleasePoint j in JailReleasePoints) + foreach (JailReleasePoint j in JailReleasePoints) { NAPI.Marker.CreateMarker(1, new Vector3(j.Position.X, j.Position.Y, j.Position.Z - 2), new Vector3(j.Position.X, j.Position.Y, j.Position.Z + 1), new Vector3(0, 0, 0), 1.5f, new Color(255, 255, 255, 50), false, 0); NAPI.TextLabel.CreateTextLabel("Gefängnis PC - Dr\u00fccke ~y~E", j.Position, 7, 1, 0, new Color(255, 255, 255), false, 0); } #endregion + #region ElevetaorPoints + ElevatorPoint FibElevatorPointEG = new ElevatorPoint() + { + Position = new Vector3(136.1958, -761.657, 242.152), //FBI oben + FactionId = 3, + Stage = "Büro" + }; + ElevatorPoint FibElevatorPointIntern = new ElevatorPoint() + { + Position = new Vector3(136.1958, -761.7176, 45.75203), //FBI unten + FactionId = 3, + Stage = "EG" + }; + ElevatorPoint FibElevatorPointGarage = new ElevatorPoint() + { + Position = new Vector3(124.2521, -741.3329, 33.13322), //FBI ganz ganz unten + FactionId = 3, + Stage = "Garage" + }; + + ElevatorPoints.Add(FibElevatorPointEG); + ElevatorPoints.Add(FibElevatorPointIntern); + ElevatorPoints.Add(FibElevatorPointGarage); + + foreach (ElevatorPoint j in ElevatorPoints) + { + NAPI.Marker.CreateMarker(1, new Vector3(j.Position.X, j.Position.Y, j.Position.Z - 2), new Vector3(j.Position.X, j.Position.Y, j.Position.Z + 1), + new Vector3(0, 0, 0), 1.5f, new Color(255, 255, 255, 50), false, 0); + NAPI.TextLabel.CreateTextLabel("Aufzug - Dr\u00fccke ~y~E", j.Position, 7, 1, 0, new Color(255, 255, 255), false, 0); + } + #endregion } } @@ -117,6 +157,12 @@ namespace ReallifeGamemode.Server.Managers { public Vector3 Position { get; set; } } + public class ElevatorPoint + { + public Vector3 Position { get; set; } + public int FactionId { get; set; } + public string Stage { get; set; } + } }