From 5c84dc177d2f9c88aadae9ab74cd63c1d9e2c65e Mon Sep 17 00:00:00 2001 From: VegaZ Date: Thu, 27 Dec 2018 22:21:59 +0100 Subject: [PATCH] Start Medic System / FactionInteraction --- Client/Gui/deathscreen.js | 1 + Client/Interaction/factioninteraction.js | 62 +++++++++++++++++++ .../{interaction.js => playerinteraction.js} | 8 +-- Client/Player/keys.js | 24 ++++++- Client/index.js | 9 ++- Server/Events/Death.cs | 15 +++++ Server/Events/Key.cs | 20 ++++-- Server/Factions/Medic/Medic.cs | 53 ++++++++++++++++ Server/Factions/Medic/MedicTask.cs | 25 ++++++++ Server/Managers/InteractionManager.cs | 8 +++ 10 files changed, 210 insertions(+), 15 deletions(-) create mode 100644 Client/Interaction/factioninteraction.js rename Client/Interaction/{interaction.js => playerinteraction.js} (98%) create mode 100644 Server/Factions/Medic/Medic.cs create mode 100644 Server/Factions/Medic/MedicTask.cs diff --git a/Client/Gui/deathscreen.js b/Client/Gui/deathscreen.js index b25bf574..ebecae07 100644 --- a/Client/Gui/deathscreen.js +++ b/Client/Gui/deathscreen.js @@ -26,6 +26,7 @@ mp.events.add("startDeathTimer", (isAdmin) => { else { mp.gui.chat.activate(false); } + mp.game.audio.playSoundFrontend(-1, "Bed", "WastedSounds", true); deathDate = new Date(); respawnTime = Math.floor(deathDate.getTime() / 1000 + 120); fade = 255 - 120; diff --git a/Client/Interaction/factioninteraction.js b/Client/Interaction/factioninteraction.js new file mode 100644 index 00000000..1b0fe6cf --- /dev/null +++ b/Client/Interaction/factioninteraction.js @@ -0,0 +1,62 @@ +let screenRes = mp.game.graphics.getScreenResolution(0, 0); + +const NativeUI = require("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; + +mp.events.add("showFactionInteraction", (userFactionId, userFactionName, isFactionLeader, reviveTaskCount, healTaskCount, fireTaskCount) => { + + mp.gui.chat.activate(false); + globalData.Interaction = true; + + + let factionInteractionMenu = new Menu("Fraktionsinteraktion", userFactionName, new Point(0, screenRes.y / 2)); + + if (isFactionLeader) { + let leaderMenu = new UIMenuItem("Leadermen\u00fc", "Verwaltung der Fraktion"); + leaderMenu.SetRightBadge(BadgeStyle.Star); + factionInteractionMenu.AddItem(leaderMenu); + } + + switch (userFactionId) { + case 2: + let reviveTaskMenu = new UIMenuItem("Reviveauftr\u00e4ge"); + reviveTaskMenu.SetRightLabel(reviveTaskCount.toString()) + factionInteractionMenu.AddItem(reviveTaskMenu); + + let healTaskMenu = new UIMenuItem("Healauftr\u00e4ge"); + reviveTaskMenu.SetRightLabel(healTaskCount.toString()) + factionInteractionMenu.AddItem(healTaskMenu); + + let fireTaskMenu = new UIMenuItem("Reviveauftr\u00e4ge"); + reviveTaskMenu.SetRightLabel(fireTaskCount.toString()) + factionInteractionMenu.AddItem(fireTaskMenu); + break; + } + + let cancelItem = new UIMenuItem("Schlie\u00dfen", "Schlie\u00dft die Spielerinteraktion"); + cancelItem.BackColor = new Color(213, 0, 0); + cancelItem.HighlightedBackColor = new Color(229, 57, 53); + factionInteractionMenu.AddItem(cancelItem); + + factionInteractionMenu.Visible = true; + + factionInteractionMenu.ItemSelect.on((item) => { + if (item.Text === "Schlie\u00dfen") { + factionInteractionMenu.Visible = false; + mp.gui.chat.activate(true); + globalData.Interaction = false; + } + }); + + factionInteractionMenu.MenuClose.on(() => { + mp.gui.chat.activate(true); + globalData.Interaction = false; + }); +}); \ No newline at end of file diff --git a/Client/Interaction/interaction.js b/Client/Interaction/playerinteraction.js similarity index 98% rename from Client/Interaction/interaction.js rename to Client/Interaction/playerinteraction.js index bad2e0be..17a68373 100644 --- a/Client/Interaction/interaction.js +++ b/Client/Interaction/playerinteraction.js @@ -42,7 +42,7 @@ const Color = NativeUI.Color; mp.events.add("showPlayerInteraction", (nearPlayerArr) => { mp.gui.chat.activate(false); nearbyPlayers = JSON.parse(nearPlayerArr); - globalData.PlayerInteraction = true; + globalData.Interaction = true; let playerInteractionMenu = new Menu("Spielerinteraktion", "", new Point(0, screenRes.y / 2)); let playerSelect = new UIMenuListItem("Mit", "~y~W\u00e4hle den Spieler aus.", new ItemsCollection(nearbyPlayers)); playerInteractionMenu.AddItem(playerSelect); @@ -60,17 +60,17 @@ mp.events.add("showPlayerInteraction", (nearPlayerArr) => { mp.events.callRemote("openTradeInventory", playerSelect.SelectedValue); playerInteractionMenu.Visible = false; mp.gui.chat.activate(true); - globalData.PlayerInteraction = false; + globalData.Interaction = false; } else if (item.Text === "Schlie\u00dfen") { playerInteractionMenu.Visible = false; mp.gui.chat.activate(true); - globalData.PlayerInteraction = false; + globalData.Interaction = false; } }); playerInteractionMenu.MenuClose.on(() => { mp.gui.chat.activate(true); - globalData.PlayerInteraction = false; + globalData.Interaction = false; }); }); diff --git a/Client/Player/keys.js b/Client/Player/keys.js index 9a9aae39..4ef12dc5 100644 --- a/Client/Player/keys.js +++ b/Client/Player/keys.js @@ -6,7 +6,6 @@ //https://docs.microsoft.com/de-de/windows/desktop/inputdev/virtual-key-codes -var chat = false; var showInventory = false; var showGui = true; var showInv = false; @@ -22,12 +21,31 @@ mp.keys.bind(0x0D, false, function () { //LEFT ARROW (Interaktion mit anderen Spielern) mp.keys.bind(0x25, false, function () { - if (!globalData.InChat && !showInv && !globalData.PlayerInteraction) { - mp.events.callRemote("keyPress:LEFT_ARROW"); + if (!globalData.InChat && !showInv && !globalData.Interaction) { + mp.events.callRemote("keyPress:LEFT_ARROW"); } }); +//UP ARROW (Interaktion mit anderen Spielern) +mp.keys.bind(0x26, false, function () { + if (!globalData.InChat && !showInv && !globalData.Interaction) { + mp.events.callRemote("keyPress:UP_ARROW"); + } +}); +//RIGHT ARROW (Interaktion mit anderen Spielern) +mp.keys.bind(0x27, false, function () { + if (!globalData.InChat && !showInv && !globalData.Interaction) { + mp.events.callRemote("keyPress:RIGHT_ARROW"); + } +}); + +//DOWN ARROW (Interaktion mit anderen Spielern) +mp.keys.bind(0x28, false, function () { + if (!globalData.InChat && !showInv && !globalData.Interaction) { + mp.events.callRemote("keyPress:DOWN_ARROW"); + } +}); //F7 //Unshowalles mp.keys.bind(0x76, false, function () { if (showGui === true) { diff --git a/Client/index.js b/Client/index.js index f94dcb48..7f3182ad 100644 --- a/Client/index.js +++ b/Client/index.js @@ -2,12 +2,12 @@ * @overview Life of German Reallife - Login index.js * @author VegaZ, hydrant * @copyright (c) 2008 - 2018 Life of German - */ + **/ let globalData = { InTuning: false, HideGui: false, - PlayerInteraction: false, + Interaction: false, InChat: false }; @@ -19,6 +19,7 @@ require('./Business/main.js'); require('./Business/cardealer.js'); require('./CharCreator/index.js'); + require('./coloredhlights'); require('./DoorManager/doormanager.js'); @@ -33,7 +34,8 @@ require('./Gui/Inventory/inventory.js'); require('./Gui/vehiclemenu/main.js'); require('./Gui/interiors.js'); -require('./Interaction/interaction.js'); +require('./Interaction/factioninteraction.js'); +require('./Interaction/playerinteraction.js'); require('./Login/main.js'); @@ -43,6 +45,7 @@ require('./Player/quit.js'); require('./Player/freecam.js'); require('./Save/main.js'); + require('./Speedometer/index.js'); require('./Tuning/main.js'); diff --git a/Server/Events/Death.cs b/Server/Events/Death.cs index 578072f6..35172b26 100644 --- a/Server/Events/Death.cs +++ b/Server/Events/Death.cs @@ -6,6 +6,7 @@ using GTANetworkAPI; using GTANetworkMethods; using reallife_gamemode.Model; using reallife_gamemode.Server.Extensions; +using reallife_gamemode.Server.Factions.Medic; using reallife_gamemode.Server.Services; using reallife_gamemode.Server.Util; @@ -76,6 +77,20 @@ namespace reallife_gamemode.Server.Events ChatService.BroadcastAdmin(message, AdminLevel.ADMIN); } } + //MEDIC AUFTRAG + MedicTask reviveTask = new MedicTask() + { + Victim = player, + Position = player.Position, + CauseOfDeath = reason.ToString(), + Caller = player, + Description = "Gestorben", + Time = DateTime.Now, + Type = 0 + }; + Medic.AddTaskToList(reviveTask); + + //TODO PICTURE NOTIFICATION + SOUND für Medics using (var userDeath = new DatabaseContext()) { diff --git a/Server/Events/Key.cs b/Server/Events/Key.cs index bed77d1e..bc688146 100644 --- a/Server/Events/Key.cs +++ b/Server/Events/Key.cs @@ -8,6 +8,7 @@ using reallife_gamemode.Model; using reallife_gamemode.Server.Classes; using reallife_gamemode.Server.Entities; using reallife_gamemode.Server.Extensions; +using reallife_gamemode.Server.Factions.Medic; using reallife_gamemode.Server.Inventory; using reallife_gamemode.Server.Inventory.Interfaces; using reallife_gamemode.Server.Managers; @@ -60,12 +61,21 @@ namespace reallife_gamemode.Server.Events } player.TriggerEvent("showPlayerInteraction", JsonConvert.SerializeObject(nearbyPlayerList)); } - else - { - player.SendNotification("~r~Es ist niemand in deiner N\u00e4he!", false); - } } - + [RemoteEvent("keyPress:RIGHT_ARROW")] + public void KeyPressRightArrow(Client player) + { + if (!player.IsLoggedIn()) return; + User user = player.GetUser(); + switch (user.FactionId) + { + //LSFD + case 2: + player.TriggerEvent("showFactionInteraction", user.FactionId, user.GetFaction().Name, user.FactionLeader, Medic.ReviveTasks.Count, Medic.HealTasks.Count, Medic.FireTasks.Count); + break; + } + } + [RemoteEvent("keyPress:E")] public void KeyPressE(Client player) { diff --git a/Server/Factions/Medic/Medic.cs b/Server/Factions/Medic/Medic.cs new file mode 100644 index 00000000..a74f82bd --- /dev/null +++ b/Server/Factions/Medic/Medic.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Text; +using GTANetworkAPI; + +/** + * @overview Life of German Reallife - Server Factions Medic Medic.cs + * @author VegaZ + * @copyright (c) 2008 - 2018 Life of German + */ + + +namespace reallife_gamemode.Server.Factions.Medic +{ + public class Medic : Script + { + public static List ReviveTasks = new List(); + public static List HealTasks = new List(); + public static List FireTasks = new List(); + + public static void AddTaskToList(MedicTask task) + { + switch (task.Type) + { + case 0: + ReviveTasks.Add(task); + break; + case 1: + HealTasks.Add(task); + break; + case 2: + FireTasks.Add(task); + break; + } + } + + public static void RemoveTaskFromList(MedicTask task) + { + switch (task.Type) + { + case 0: + ReviveTasks.Remove(task); + break; + case 1: + HealTasks.Remove(task); + break; + case 2: + FireTasks.Remove(task); + break; + } + } + } +} diff --git a/Server/Factions/Medic/MedicTask.cs b/Server/Factions/Medic/MedicTask.cs new file mode 100644 index 00000000..0ca3ad16 --- /dev/null +++ b/Server/Factions/Medic/MedicTask.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; +using GTANetworkAPI; + +/** + * @overview Life of German Reallife - Server Factions Medic MedicTask.cs + * @author VegaZ + * @copyright (c) 2008 - 2018 Life of German + */ + + +namespace reallife_gamemode.Server.Factions.Medic +{ + public class MedicTask + { + public Client Victim { get; set; } + public Vector3 Position { get; set; } + public byte Type { get; set; } + public string CauseOfDeath { get; set; } + public string Description { get; set; } + public Client Caller { get; set; } + public DateTime Time { get; set; } + } +} diff --git a/Server/Managers/InteractionManager.cs b/Server/Managers/InteractionManager.cs index bfe31fb7..da190715 100644 --- a/Server/Managers/InteractionManager.cs +++ b/Server/Managers/InteractionManager.cs @@ -16,6 +16,11 @@ namespace reallife_gamemode.Server.Managers { public class InteractionManager : Script { + #region Umgebungsinteraktionen PFEILTASTE-HOCH + #endregion + #region Eigeninteraktionen PFEILTASTE-RUNTER + #endregion + #region Spielerinteraktionen PFEILTASTE-LINKS [RemoteEvent("openTradeInventory")] public void OpenTradeInventory(Client player, string targetPlayer) { @@ -50,5 +55,8 @@ namespace reallife_gamemode.Server.Managers tradeRequester.TriggerEvent("unlockTradeItems"); } } + #endregion + #region Fraktionsinteraktionen / Jobinteraktionen PFEILTASTE-RECHTS + #endregion } }