From fa03d86d3f6beda0c97fb548ee5a0ccda175b2cd Mon Sep 17 00:00:00 2001 From: Fabian Date: Sun, 25 Apr 2021 17:15:44 +0200 Subject: [PATCH] first draft eventport --- .../Commands/UserCommands.cs | 49 ++++++++++++++++++- .../Managers/PositionManager.cs | 3 ++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/ReallifeGamemode.Server/Commands/UserCommands.cs b/ReallifeGamemode.Server/Commands/UserCommands.cs index 1afc483c..18ce329f 100644 --- a/ReallifeGamemode.Server/Commands/UserCommands.cs +++ b/ReallifeGamemode.Server/Commands/UserCommands.cs @@ -16,7 +16,54 @@ using ReallifeGamemode.Services; namespace ReallifeGamemode.Server.Commands { internal class UserCommands : Script - { + { + [Command("eventport", "~m~eventport")] + public void CmdUserEventport(Player player, String option = "") + { + if (!player.IsLoggedIn()) return; + + if (option == "on") + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + return; + } + PositionManager.eventportPosition = player.Position; + PositionManager.eventportActive = true; + player.SendChatMessage("~y~Du hast hier erfolgreich einen Eventport gesetzt."); + return; + } + + if (option == "off") + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + return; + } + PositionManager.eventportActive = false; + player.SendChatMessage("Du hast den Eventport deaktiviert."); + return; + } + + if (!PositionManager.eventportActive || PositionManager.eventportPosition == null) + { + player.SendChatMessage("Im Moment ist kein Eventport aktiv."); + return; + } + + using (var dbContext = new DatabaseContext()) + { + User user = player.GetUser(dbContext); + if (user.Wanteds > 0 || user.JailTime > 0 || player.HasData("inGangWar") || !player.IsAlive()) + { + ChatService.ErrorMessage(player, "Momentan kannst du keinen Eventport nutzen"); + return; + } + } + + player.SafeTeleport(PositionManager.eventportPosition); + } + [Command("look", "~m~look")] public void CmdUserLook(Player player) { diff --git a/ReallifeGamemode.Server/Managers/PositionManager.cs b/ReallifeGamemode.Server/Managers/PositionManager.cs index 7a3c8c05..c23a06b3 100644 --- a/ReallifeGamemode.Server/Managers/PositionManager.cs +++ b/ReallifeGamemode.Server/Managers/PositionManager.cs @@ -32,6 +32,9 @@ namespace ReallifeGamemode.Server.Managers public static List AmmunationPoints = new List(); + public static Vector3 eventportPosition; + public static bool eventportActive = false; + public static void LoadPositionManager() { #region DutyPoints