using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text.RegularExpressions;
using GTANetworkAPI;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Entities.Logs.Chat;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Business;
using ReallifeGamemode.Server.Classes;
using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Factions.Medic;
using ReallifeGamemode.Server.Finance;
using ReallifeGamemode.Server.Inventory.Interfaces;
using ReallifeGamemode.Server.Job;
using ReallifeGamemode.Server.Managers;
using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Types;
using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Server.Wanted;
using ReallifeGamemode.Services;

/**
* @overview Life of German Reallife - Admin Commands (Admin.cs)
* @author VegaZ, hydrant, xSprite, balbo, kookroach, aviate, MichaPlays
* @copyright (c) 2008 - 2019 Life of German
*/

namespace ReallifeGamemode.Server.Commands
{
  public class AdminCommands : Script
  {
    #region Todo

    [Command("syncanim", "~m~Benutzung: ~s~/syncanim [animName]")]
    public void CmdSyncAnim(Player player, string animName = null)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      player.SyncAnimation(animName);
    }

    [Command("anim", "~m~Benutzung: ~s~/anim [animDict] [animName]")]
    public void CmdAnim(Player player, string animDict, string animName)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      NAPI.Player.PlayPlayerAnimation(player, (int)(AnimationFlags.Loop | AnimationFlags.AllowPlayerControl | AnimationFlags.Cancellable), animDict, animName);
    }

    //TODO
    [Command("fpay")]
    public void FPay(Player player, string receiver, int amount)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      using (var getFaction = new DatabaseContext())
      {
        Faction receiverUser = getFaction.Factions.Include(u => u.BankAccount).FirstOrDefault(u => u.Name == receiver);

        if (receiverUser == null)
        {
          ChatService.ErrorMessage(player, "Diese Fraktion existiert nicht");
          return;
        }

        BankManager.TransferMoney(player.GetUser(), receiverUser, amount, "/FPAY", getFaction);
      }
    }

    [Command("saveall")]
    public void SaveAll(Player player)
    {
      SaveManager.SaveAllOnSave();
    }

    [Command("hash")]
    public void CmdHash(Player player, string toHash)
    {
      string msg = $"{toHash} => {NAPI.Util.GetHashKey(toHash)}";
      NAPI.Util.ConsoleOutput(msg);
      ChatService.SendMessage(player, msg);
    }

    #endregion Todo

    #region ahelp

    /* [Command("ahelp", "~m~Benutzung: ~s~/ahelp")]
     public void CmdAdminHelp(Player player)
     {
       if (!player.GetUser()?.IsAdmin(AdminLevel.MAPPING) ?? true)
       {
         ChatService.NotAuthorized(player);
         return;
       }
       else
       {
         switch (player.GetUser().AdminLevel)
         {
           case AdminLevel.MAPPING:
             ChatService.SendMessage(player, "~b~ " + "/team, /tc, /position");
             break;

           case AdminLevel.SUPPORTER:
             player.TriggerEvent("showShelp");
             break;

           case AdminLevel.ADMIN:
             player.TriggerEvent("showAhelp");
             break;
         }
       }
     }
     */

    #endregion ahelp

    #region Mapping / Entwicklung

    [Command("team", "~m~Benutzung: ~s~/team")]
    public void CmdAdminTeam(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.MAPPING) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      ChatService.SendMessage(player, "Online Teammitglieder:");

      List<Player> playerlist = NAPI.Pools.GetAllPlayers().FindAll(c => c.GetUser()?.IsAdmin(AdminLevel.MAPPING) ?? false).OrderByDescending(c => c.GetUser().AdminLevel).ToList();
      foreach (Player currentPlayer in playerlist)
      {
        ChatService.SendMessage(player, currentPlayer.GetUser().AdminLevel.GetName() + " | " + currentPlayer.Name + " | ID: " + currentPlayer.Handle.Value);
      }
    }

    [Command("tc", "~m~Benutzung: ~s~/tc [Nachricht]", GreedyArg = true)]
    public void CmdTeamC(Player player, string message)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.MAPPING) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");

      ChatService.BroadcastAdmin("!{#578A83}** TC " + player.Name + ":~w~ " + message, AdminLevel.MAPPING);
    }

    [Command("position", "~m~Benutzung: ~s~/position")]
    public void CmdAdminPosition(Player player)
    {
      ChatService.SendMessage(player, "Position: X Y Z: " + player.Position + " Richtung: " + player.Heading);
    }

    #endregion Mapping / Entwicklung

    #region Support

    [Command("tog", "~m~Benutzung: ~s~/tog [Typ = ~g~IP~s~, ~g~deathlogs~s~, ~g~LC~s~, ~g~Connect~s~, ~g~D~s~, ~g~GA~s~, ~g~All~s~]", GreedyArg = true)]
    public void CmdAdminTog(Player player, string typ, string option1 = null, string option2 = null)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      switch (typ.ToLower())
      {
        case "ip":
          if (player.HasData("togip"))
          {
            player.ResetData("togip");
            player.SendNotification("~g~[Info]~w~ Ip´s werden nun ausgeblendet.");
          }
          else
          {
            player.SetData("togip", true);
            player.SendNotification("~g~[Info]~w~ Ip´s werden nun angezeigt.");
          }
          break;

        case "deathlogs":
          if (player.HasData("togdeath"))
          {
            player.ResetData("togdeath");
            player.SendNotification("~g~[Info]~w~ Deathlogs werden nun ausgeblendet.");
          }
          else
          {
            player.SetData("togdeath", true);
            player.SendNotification("~g~[Info]~w~ Deathlogs werden nun angezeigt.");
          }
          break;

        case "lc":
          if (player.HasData("toglc"))
          {
            player.ResetData("toglc");
            player.SendNotification("~g~[Info]~w~ Leaderchat wird nun ausgeblendet.");
          }
          else
          {
            player.SetData("toglc", true);
            player.SendNotification("~g~[Info]~w~ Leaderchat wird nun angezeigt.");
          }
          break;

        case "connect":
          if (player.HasData("togconnect"))
          {
            player.ResetData("togconnect");
            player.SendNotification("~g~[Info]~w~ Connect-Logs werden nun ausgeblendet.");
          }
          else
          {
            player.SetData("togconnect", true);
            player.SendNotification("~g~[Info]~w~ Connect-Logs werden nun angezeigt.");
          }
          break;
        case "d":
          if (player.HasData("togd"))
          {
            player.ResetData("togd");
            player.SendNotification("~g~[Info]~w~ D-Chat wird nun ausgeblendet.");
          }
          else
          {
            player.SetData("togd", true);
            player.SendNotification("~g~[Info]~w~ D-Chat wird nun angezeigt.");
          }
          break;
        case "ga":
          if (player.HasData("togga"))
          {
            player.ResetData("togga");
            player.SendNotification("~g~[Info]~w~ GA-Chat wird nun ausgeblendet.");
          }
          else
          {
            player.SetData("togga", true);
            player.SendNotification("~g~[Info]~w~ GA-Chat wird nun angezeigt.");
          }
          break;
        case "all":
          if (!player.HasData("togall"))
          {
            player.SetData("togip", true);
            player.SetData("togdeath", true);
            player.SetData("togdeathlogs", true);
            player.SetData("toglc", true);
            player.SetData("togconnect", true);
            player.SetData("togd", true);
            player.SetData("togga", true);
            player.SetData("togall", true);

            player.SendNotification("~g~[Info]~s~ Alle Logs wurden eingeschaltet");
          }
          else
          {
            player.ResetData("togip");
            player.ResetData("togdeath");
            player.ResetData("togdeathlogs");
            player.ResetData("toglc");
            player.ResetData("togconnect");
            player.ResetData("togd");
            player.ResetData("togga");
            player.ResetData("togall");

            player.SendNotification("~g~[Info]~s~ Alle Logs wurden ausgeschaltet");
          }
          break;
      }
    }

    [Command("tsupport", "~m~Benutzung: ~s~/tsupport", Alias = "ts")]
    public void CmdAdminTSupport(Player player)
    {
      User user = player.GetUser();
      if (!user.IsAdmin(AdminLevel.SUPPORTER))
      {
        ChatService.NotAuthorized(player);
        return;
      }
      if (!player.IsAdminDuty())
      {
        ChatService.SendMessage(player, "~r~ Du bist nicht im Admin-Duty-Modus!");
        return;
      }
      if (player.GetData<bool>("SAdminduty") == false)
      {
        player.TriggerEvent("toggleTSupportMode", true);
        player.SetData("SAdminduty", true);
        ChatService.SendMessage(player, "~g~ ** " + "Du befindest dich im T-Support");
      }
      else
      {
        player.TriggerEvent("toggleTSupportMode", false);
        player.SetData("SAdminduty", false);
        ChatService.SendMessage(player, "!{#ee4d2e}** " + "Du befindest dich nicht mehr im T-Support");

        if (user.GetData<bool>("adminUnshow") == true)
        {
          user.SetData("adminUnshow", false);
          player.TriggerEvent("toggleAdminUnshowMode", false);
        }
      }
      user.SetBlipAndNametagColor();
    }

    [Command("aduty", "~m~Benutzung: ~s~/aduty")]
    public void CmdAdminAduty(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (player.GetData<bool>("Adminduty") == false)
      {
        player.SetData("Adminduty", true);
        ChatService.Broadcast("~g~[SUPPORT] " + player.Name + " hat sich zum Support angemeldet");

        player.TriggerEvent("toggleADutyMode", true);
      }
      else
      {
        if (player.GetData<bool>("SAdminduty"))
        {
          CmdAdminTSupport(player);
        }

        player.SetData("Adminduty", false);
        ChatService.Broadcast("!{#ee4d2e}[SUPPORT] " + player.Name + " hat sich vom Support abgemeldet");

        player.TriggerEvent("toggleADutyMode", false);
      }
    }

    [Command("o", "~m~Benutzung: ~s~/o [Nachricht]", GreedyArg = true)]
    public void CmdAdminO(Player player, string message)
    {
      if (!player.IsLoggedIn())
      {
        return;
      }

      using var dbContext = new DatabaseContext();
      User user = player.GetUser(dbContext);

      if (!user.IsAdmin(AdminLevel.SUPPORTER))
      {
        ChatService.NotAuthorized(player);
        return;
      }

      message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");

      var logEntry = new OChatLogEntry()
      {
        Text = message,
        UserId = user.Id,
      };

      dbContext.OChatLogs.Add(logEntry);
      dbContext.SaveChanges();

      message = Regex.Replace(message, "#([0-9A-Fa-f]{6})", m => "!{" + m.Groups[0].Value + "}");

      string publicMessage = "~b~(( " + player.GetUser().AdminLevel.GetName() + " " + player.Name + ": " + message + " ~b~))";
      ChatService.Broadcast(publicMessage);
    }

    [Command("dimension", "~m~Benutzung: ~s~/dimension")]
    public void CmdAdminDimension(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      ChatService.SendMessage(player, "Deine Dimension ist ~g~" + player.Dimension);
    }

    [Command("to", "~m~Benutzung: ~s~/to [Name]")]
    public void CmdAdminGoto(Player player, string name)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(name);

      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }
      //TODO: Als Supporter nur, wenn mit dem Ziel ein offenes Ticket besteht. Ansonsten kein Teleport
      if (player.IsInVehicle && player.VehicleSeat == 0)
      {
        player.Vehicle.Position = target.Position;
        NAPI.Entity.SetEntityVelocity(player.Vehicle, new Vector3());
      }
      else player.SafeTeleport(target.Position);
      ChatService.SendMessage(player, "~c~* Du hast dich teleportiert.");
    }

    [Command("gh", "~m~Benutzung: ~s~/gh [Name]")]
    public void CmdAdminGethere(Player player, string name)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(name);

      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      if (target.IsInVehicle && target.VehicleSeat == 0)
      {
        target.Vehicle.Position = player.Position;
        NAPI.Entity.SetEntityVelocity(target.Vehicle, new Vector3());
      }
      else target.SafeTeleport(player.Position);
      ChatService.SendMessage(target, "~c~* Du wurdest teleportiert.");
    }

    [Command("pm", "~m~Benutzung: ~s~/pm [Spieler] [Nachricht]", GreedyArg = true)]
    public void CmdAdminMsg(Player player, string name, string msg)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(name);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      if (target == player)
      {
        ChatService.ErrorMessage(player, "Du kannst dir nicht selber zuflüstern");
        return;
      }

      msg = Regex.Replace(msg, "(~[a-zA-Z]~)|(!{(.*)})", "");

      ChatService.SendMessage(player, "~y~PM an " + target.Name + ": " + msg + " ");
      string Message = "~y~PM von " + player.GetUser().AdminLevel.GetName() + " " + player.Name + ": " + msg;
      ChatService.SendMessage(target, Message);
    }

    [Command("skick", "~m~Benutzung: ~s~/skick [Spieler] [Grund]", GreedyArg = true)]
    public void CmdAdminSKick(Player player, string targetname, string reason)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(targetname);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      if (target.GetData<bool>("duty") == true)
      {
        target.SetData<bool>("duty", false);
        Medic.UpdateDutyMedics();
      }

      string adminPlayername = NAPI.Player.GetPlayerName(player);
      ChatService.SendMessage(target, "~r~INFO: ~w~Du wurdest von " + adminPlayername + " vom Server gekickt (Grund: " + reason + ").");

      NAPI.Task.Run(() =>
      {
        target.Kick();
      }, 2500);

      ChatService.BroadcastAdmin("~y~SKICK: ~w~" + target.Name + " wurde von " + player.GetUser().AdminLevel.GetName() + " " + adminPlayername + " gekickt (Grund: " + reason + ").", AdminLevel.SUPPORTER);
    }

    [Command("clearchat", "~m~Benutzung: ~s~/clearchat")]
    public void CmdAdminClearchat(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      for (int i = 0; i < 20; i++)
      {
        ChatService.Broadcast("");
      }
    }

    [Command("bitcoin", "~m~/bitcoin [ID]")]
    public void CmdAdminBitcoin(Player player, string name)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(name);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      target.TriggerEvent("CLIENT:PlaySound", "fun/bitcoinnect", "mp3", 50);
    }

    #endregion Support

    #region Admin
    [Command("towaypoint", "~m~Benutzung: ~s~/towaypoint", Alias = "tow")]
    public void CmdAdminToWaypoint(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      player.TriggerEvent("tpToWaypoint");
    }

    [Command("remspawnschutz", "~m~Benutzung: ~s~/rmss [Target]", Alias = "rmss")]
    public void CmdAdminRmss(Player player, String targetname)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(targetname);

      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      target.SendChatMessage(player.Name + " hat deinen Spawnschutz entfernt");
      player.SendChatMessage("Du hast den Spawnschutz von " + target.Name + " entfernt");
      target.TriggerEvent("abortSpawnschutz");

    }

    [Command("countdown", "~m~Benutzung: ~s~/countdown [Zeit] [Text]", GreedyArg = true)]
    public void CmdAdminCountdown(Player player, string timer_string, string text)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (timer_string == "clear")
      {
        foreach (Player c in NAPI.Pools.GetAllPlayers())
        {
          c.TriggerEvent("countdown", 0, "");
        }
        return;
      }

      if (!int.TryParse(timer_string, out int timer))
      {
        ChatService.ErrorMessage(player, "Die Zeit muss eine Ganzzahl sein");
        return;
      }

      GlobalHelper.CountdownUntil = DateTime.Now + TimeSpan.FromSeconds(timer);
      GlobalHelper.CountdownText = text;

      NAPI.ClientEvent.TriggerClientEventForAll("countdown", timer, text);
    }

    [Command("ac", "~m~Benutzung: ~s~/ac [Nachricht]", GreedyArg = true)]
    public void CmdAdminA(Player player, string message)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");

      ChatService.BroadcastAdmin("!{#1db992}** AC " + player.Name + ":~w~ " + message, AdminLevel.ADMIN);
    }

    [Command("gotolist", "~m~Benutzung: ~s~/gotolist")]         //TODO Als Browser anzeigeN??
    public void CmdAdminGotoList(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      var gotoString = "";
      using (var dbContext = new DatabaseContext())
      {
        foreach (GotoPoint point in dbContext.GotoPoints)
        {
          if (point.Active)
          {
            gotoString += point.Description + ", ";
          }
        }
      }
      ChatService.SendMessage(player, gotoString);
    }

    [Command("mark", "~m~Benutzung: ~s~/mark")]
    public void CmdAdminMark(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      player.SetData("mark", player.Position);
      player.SendNotification("~y~Mark ~s~gespeichert", true);
    }

    [Command("gotomark", "~m~Benutzung: ~s~/gotomark")]
    public void CmdAdminGotoMark(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (!player.HasData("mark"))
      {
        ChatService.ErrorMessage(player, "Du hast noch keine Markierung gesetzt. ~m~(/mark)");
        return;
      }

      if (player.IsInVehicle && player.VehicleSeat == 0) player.Vehicle.Position = player.GetData<Vector3>("mark");
      else player.SafeTeleport(player.GetData<Vector3>("mark"));
    }

    [Command("flip", "")]
    public void CmdAdminFlip(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (player.IsInVehicle)
      {
        player.Vehicle.Rotation = new Vector3(0.0, 0.0, player.Vehicle.Rotation.Z);
      }
      else
      {
        player.SendChatMessage("~r~Du befindest dich in keinem Fahrzeug!");
      }
    }

    [Command("up", "~m~Benutzung: ~s~/up [Wert]")]
    public void CmdAdminUp(Player player, int value = 5)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (player.IsInVehicle)
      {
        player.Vehicle.Position = new Vector3(player.Vehicle.Position.X, player.Vehicle.Position.Y, player.Vehicle.Position.Z + value);
      }
      else
      {
        player.SafeTeleport(new Vector3(player.Position.X, player.Position.Y, player.Position.Z + value));
      }
    }

    [Command("dn", "~m~Benutzung: ~s~/dn [Wert]")]
    public void CmdAdminDn(Player player, int value = 5)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (player.IsInVehicle)
      {
        player.Vehicle.Position = new Vector3(player.Vehicle.Position.X, player.Vehicle.Position.Y, player.Vehicle.Position.Z - value);
      }
      else
      {
        player.SafeTeleport(new Vector3(player.Position.X, player.Position.Y, player.Position.Z - value));
      }
    }

    [Command("rt", "~m~Benutzung: ~s~/rt [Wert]")]
    public void CmdAdminRt(Player player, int value = 5)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      float playerHeading = player.Heading;

      if (playerHeading < 45 || playerHeading >= 315)
      {
        Vector3 playerPosition = new Vector3(player.Position.X + value, player.Position.Y, player.Position.Z);
        if (player.IsInVehicle && player.VehicleSeat == 0) player.Vehicle.Position = playerPosition;
        else player.SafeTeleport(playerPosition);
      }
      else if (playerHeading < 315 && playerHeading >= 225)
      {
        Vector3 playerPosition = new Vector3(player.Position.X, player.Position.Y - value, player.Position.Z);
        if (player.IsInVehicle && player.VehicleSeat == 0) player.Vehicle.Position = playerPosition;
        else player.SafeTeleport(playerPosition);
      }
      else if (playerHeading >= 135 && playerHeading < 225)
      {
        Vector3 playerPosition = new Vector3(player.Position.X - value, player.Position.Y, player.Position.Z);
        if (player.IsInVehicle && player.VehicleSeat == 0) player.Vehicle.Position = playerPosition;
        else player.SafeTeleport(playerPosition);
      }
      else if (playerHeading >= 45 && playerHeading < 135)
      {
        Vector3 playerPosition = new Vector3(player.Position.X, player.Position.Y + value, player.Position.Z);
        if (player.IsInVehicle && player.VehicleSeat == 0) player.Vehicle.Position = playerPosition;
        else player.SafeTeleport(playerPosition);
      }
    }

    [Command("lt", "~m~Benutzung: ~s~/lt [Wert]")]
    public void CmdAdminLt(Player player, int value = 5)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      float playerHeading = player.Heading;

      if (playerHeading < 45 || playerHeading >= 315)
      {
        Vector3 playerPosition = new Vector3(player.Position.X - value, player.Position.Y, player.Position.Z);
        if (player.IsInVehicle && player.VehicleSeat == 0) player.Vehicle.Position = playerPosition;
        else player.SafeTeleport(playerPosition);
      }
      else if (playerHeading < 315 && playerHeading >= 225)
      {
        Vector3 playerPosition = new Vector3(player.Position.X, player.Position.Y + value, player.Position.Z);
        if (player.IsInVehicle && player.VehicleSeat == 0) player.Vehicle.Position = playerPosition;
        else player.SafeTeleport(playerPosition);
      }
      else if (playerHeading >= 135 && playerHeading < 225)
      {
        Vector3 playerPosition = new Vector3(player.Position.X + value, player.Position.Y, player.Position.Z);
        if (player.IsInVehicle && player.VehicleSeat == 0) player.Vehicle.Position = playerPosition;
        else player.SafeTeleport(playerPosition);
      }
      else if (playerHeading >= 45 && playerHeading < 135)
      {
        Vector3 playerPosition = new Vector3(player.Position.X, player.Position.Y - value, player.Position.Z);
        if (player.IsInVehicle && player.VehicleSeat == 0) player.Vehicle.Position = playerPosition;
        else player.SafeTeleport(playerPosition);
      }
    }

    [Command("setdimension", "~m~Benutzung: ~s~/setdimension [Spieler] [Dimension]")]
    public void CmdAdminSetDimension(Player player, string targetname, uint dimension)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(targetname);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }
      target.Dimension = dimension;
      ChatService.SendMessage(target, "~s~Deine Dimension wurde auf ~g~" + dimension + "~s~ geändert.");
      ChatService.SendMessage(player, "~s~Die Dimension von ~y~" + target.Name + " ~s~wurde auf ~g~" + dimension + "~s~ geändert.");
    }

    [Command("kick", "~m~Benutzung: ~s~/kick [Player] [Grund]", GreedyArg = true)]
    public void CmdAdminKick(Player player, string targetname, string reason)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(targetname);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      if (target.GetData<bool>("duty") == true)
      {
        target.SetData<bool>("duty", false);
        Medic.UpdateDutyMedics();
      }

      string adminPlayername = NAPI.Player.GetPlayerName(player);

      ChatService.SendMessage(target, "~r~INFO: ~w~Du wurdest von " + adminPlayername + " vom Server gekickt (Grund: " + reason + ").");

      NAPI.Task.Run(() =>
      {
        target.Kick();
      }, 2500);

      ChatService.Broadcast("!{#FF4040}[KICK] ~w~" + target.Name + " wurde von " + player.GetUser().AdminLevel.GetName() + " " + adminPlayername + " gekickt (Grund: " + reason + ").");
    }

    [Command("warn", "~m~Benutzung: ~s~/warn [Player] [Grund]", GreedyArg = true)]
    public void CmdAdminWarn(Player player, string targetname, string reason)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(targetname);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      string targetPlayername = NAPI.Player.GetPlayerName(target);
      string adminPlayername = NAPI.Player.GetPlayerName(player);

      using (var dbContext = new DatabaseContext())
      {
        User userwarn = player.GetUser(dbContext);

        userwarn.warn++;
        dbContext.SaveChanges();
        if (userwarn.warn >= 3)
        {
          ChatService.BroadcastAdmin("~y~INFO: ~w~" + targetPlayername + " hat jetzt drei Warns – bitte bannen!", AdminLevel.ADMIN);
        }
      }

      ChatService.SendMessage(target, "!{#FF4040}[WARN] ~w~Du wurdest von " + adminPlayername + " verwarnt (Grund: " + reason + ").");

      ChatService.BroadcastAdmin("~y~INFO: " + targetPlayername + " ~w~wurde von " + player.GetUser().AdminLevel.GetName() + " ~y~" + adminPlayername + " ~w~verwarnt (Grund: " + reason + ").", AdminLevel.ADMIN);
    }

    [Command("ip", "~m~Benutzung: ~s~/ip [Spieler]")]
    public void CmdAdminIp(Player player, string targetname)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(targetname);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }
      ChatService.SendMessage(player, "~y~IP: ~w~Die IP-Adresse von ~y~" + NAPI.Player.GetPlayerName(target) + " ~w~lautet: ~y~" + target.Address);
    }

    [Command("ban", "~m~Benutzung: ~s~/ban [User] [Zeit in Minuten (0 = Permanent)] [Grund]", GreedyArg = true)]
    public void CmdAdminBan(Player admin, string user, string strmins, string reason)
    {
      if (!admin.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(admin);
        return;
      }

      if (!int.TryParse(strmins, out int mins) && mins < 0)
      {
        ChatService.ErrorMessage(admin, "Ungültige Zeitangabe");
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(user);

      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(admin);
        return;
      }

      if (target.GetData<bool>("duty") == true)
      {
        target.SetData<bool>("duty", false);
        Medic.UpdateDutyMedics();
      }

      reason = Regex.Replace(reason, "(~[a-zA-Z]~)|(!{(.*)})", "");

      string adminPlayername = NAPI.Player.GetPlayerName(admin);
      String banMessage = "~r~INFO: ~w~Du wurdest von " + adminPlayername + " permanent vom Server gebannt (Grund: " + reason + ").";

      if (mins > 0)
      {
        banMessage = "~r~INFO: ~w~Du wurdest von " + adminPlayername + " für " + mins + " Minuten vom Server gebannt (Grund: " + reason + ").";
      }

      ChatService.SendMessage(target, banMessage);

      NAPI.Task.Run(() =>
      {
        target.GetUser().BanPlayer(admin, reason, mins);
      }, 2500);
    }

    [Command("unban", "~m~Benutzung: ~s~/unban [Name]")]
    public void CmdAdminUnban(Player admin, string userName)
    {
      if (!admin.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(admin);
        return;
      }

      User user;

      using (var dbContext = new DatabaseContext())
      {
        user = dbContext.Users.FirstOrDefault(u => u.Name == userName);
        if (user == null)
        {
          ChatService.ErrorMessage(admin, "Dieser Spieler existiert nicht");
          return;
        }

        if (user.BanId == null)
        {
          ChatService.ErrorMessage(admin, "Dieser Spieler ist nicht gebannt");
          return;
        }

        Ban ban = dbContext.Bans.FirstOrDefault(b => b.Id == user.BanId);
        if (ban == null)
        {
          ChatService.ErrorMessage(admin, "Dieser Spieler ist nicht gebannt");
          return;
        }

        if (ban.Applied == ban.UntilDateTime)
        {
          user.UnbanPlayer();
        }
        else
        {
          int currentTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
          if (ban.UntilDateTime < currentTimestamp)
          {
            ChatService.ErrorMessage(admin, "Dieser Spieler ist nicht gebannt");
            return;
          }
        }
        user.UnbanPlayer();
      }

      string message = "~y~INFO: ~w~Der Spieler ~y~" + user.Name + " ~w~wurde von ~y~" + admin.Name + " ~w~entbannt.";
      ChatService.BroadcastAdmin(message, AdminLevel.ADMIN);
    }

    [Command("goto", "~m~Benutzung: ~s~/goto [Ort]")]
    public void CmdAdminGotoPoint(Player player, string location)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      using (var dbContext = new DatabaseContext())
      {
        GotoPoint p = dbContext.GotoPoints.FirstOrDefault(x => x.Description == location);

        if (p == null)
        {
          ChatService.ErrorMessage(player, "Dieser Goto-Punkt existiert nicht");
          return;
        }

        if (player.IsInVehicle && player.VehicleSeat == 0)
        {
          player.Vehicle.Position = new Vector3(p.X, p.Y, p.Z);
          NAPI.Entity.SetEntityVelocity(player.Vehicle, new Vector3());
        }
        else player.SafeTeleport(new Vector3(p.X, p.Y, p.Z));
      }
    }

    [Command("destroyped", "~m~Benutzung: ~s~/destroyped [PedNr]")]
    public void CmdAdminAddPPed(Player player, int PedNr)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      player.TriggerEvent("CLIENT:DestroyPed", PedNr);
      //NAPI.Ped.CreatePed(PedHash.Bankman, new Vector3(player.Position.X, player.Position.Y, player.Position.Z), player.Heading, dimension);
    }

    [Command("addpped", "~m~Benutzung: ~s~/addpped [PedNr] [model] [dimension] [Dynamic] [Freezed] [Collision(0-3)] [Weapon] [AttackProof] [Fire/Explosion-Proof] [DrownProof]")]
    public void CmdAdminAddPPed(Player player, Array PedNr, string model, uint dimension = 0, bool dynamic = false, bool freeze = false, int collision = 0, string weapon = "none", bool attackproof = false, bool fireexplosionproof = false, bool drownproof = false)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      player.TriggerEvent("CLIENT:AddPed", PedNr, model, player.Position.X, player.Position.Y, player.Position.Z, player.Heading, dimension, dynamic, freeze, collision, weapon, attackproof, fireexplosionproof, drownproof);
      //NAPI.Ped.CreatePed(PedHash.Bankman, new Vector3(player.Position.X, player.Position.Y, player.Position.Z), player.Heading, dimension);
    }

    [Command("addmped", "~m~Benutzung: ~s~/addmped [model] [dimension]")]
    public void CmdAdminAddMPed(Player player, int model, uint dimension = 0)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      player.TriggerEvent("CLIENT:AddPedModel", model, player.Position.X, player.Position.Y, player.Position.Z, player.Heading, dimension);
      //NAPI.Ped.CreatePed(PedHash.Bankman, new Vector3(player.Position.X, player.Position.Y, player.Position.Z), player.Heading, dimension);
    }

    [Command("addgped", "~m~Benutzung: ~s~/addgped")]
    public void CmdAdminAddGPed(Player player, int model, uint dimension = 0)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      //player.TriggerEvent("CLIENT:AddPed", model, player.Position.X, player.Position.Y, player.Position.Z, player.Heading, dimension);
      Ped Peter = NAPI.Ped.CreatePed(PedHash.Bankman, new Vector3(player.Position.X, player.Position.Y, player.Position.Z), player.Heading, dimension);

      //Peter.freezePosition(true);
    }

    [Command("addgpedmore", "~m~Benutzung: ~s~/addgpedMore")]
    public void CmdAdminAddGPedMore(Player player, int model, uint dimension = 0)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      //player.TriggerEvent("CLIENT:AddPed", model, player.Position.X, player.Position.Y, player.Position.Z, player.Heading, dimension);
      Ped Peter = NAPI.Ped.CreatePed(PedHash.ChickenHawk, new Vector3(player.Position.X + 1, player.Position.Y, player.Position.Z + 2), player.Heading, dimension);
      Ped Peter2 = NAPI.Ped.CreatePed(PedHash.MovAlien01, new Vector3(player.Position.X + 2, player.Position.Y, player.Position.Z), player.Heading, dimension);
      Ped Peter3 = NAPI.Ped.CreatePed(PedHash.Chimp, new Vector3(player.Position.X + 3, player.Position.Y, player.Position.Z), player.Heading, dimension);
      Ped Peter4 = NAPI.Ped.CreatePed(PedHash.Boar, new Vector3(player.Position.X + 4, player.Position.Y, player.Position.Z), player.Heading, dimension);
      Ped Peter5 = NAPI.Ped.CreatePed(PedHash.BradCadaverCutscene, new Vector3(player.Position.X + 5, player.Position.Y, player.Position.Z + 2), player.Heading, dimension);
      Ped Peter6 = NAPI.Ped.CreatePed(PedHash.Cat, new Vector3(player.Position.X - 1, player.Position.Y, player.Position.Z), player.Heading, dimension);
      Ped Peter7 = NAPI.Ped.CreatePed(PedHash.Chop, new Vector3(player.Position.X - 2, player.Position.Y, player.Position.Z), player.Heading, dimension);
      Ped Peter8 = NAPI.Ped.CreatePed(PedHash.Cormorant, new Vector3(player.Position.X - 3, player.Position.Y, player.Position.Z), player.Heading, dimension);
      Ped Peter9 = NAPI.Ped.CreatePed(PedHash.Cow, new Vector3(player.Position.X - 4, player.Position.Y, player.Position.Z), player.Heading, dimension);
      Ped Peter10 = NAPI.Ped.CreatePed(PedHash.Deer, new Vector3(player.Position.X - 5, player.Position.Y, player.Position.Z), player.Heading, dimension);
      Ped Peter11 = NAPI.Ped.CreatePed(PedHash.Coyote, new Vector3(player.Position.X, player.Position.Y + 1, player.Position.Z), player.Heading, dimension);
      Ped Peter12 = NAPI.Ped.CreatePed(PedHash.Crow, new Vector3(player.Position.X, player.Position.Y + 2, player.Position.Z + 2), player.Heading, dimension);
      Ped Peter13 = NAPI.Ped.CreatePed(PedHash.Humpback, new Vector3(player.Position.X, player.Position.Y + 3, player.Position.Z), player.Heading, dimension);
      Ped Peter14 = NAPI.Ped.CreatePed(PedHash.Husky, new Vector3(player.Position.X, player.Position.Y + 4, player.Position.Z), player.Heading, dimension);
      Ped Peter15 = NAPI.Ped.CreatePed(PedHash.JohnnyKlebitz, new Vector3(player.Position.X, player.Position.Y + 5, player.Position.Z - 1), player.Heading, dimension);
      Ped Peter16 = NAPI.Ped.CreatePed(PedHash.Pig, new Vector3(player.Position.X, player.Position.Y - 1, player.Position.Z), player.Heading, dimension);
      Ped Peter17 = NAPI.Ped.CreatePed(PedHash.Pigeon, new Vector3(player.Position.X, player.Position.Y - 2, player.Position.Z), player.Heading, dimension);
      Ped Peter18 = NAPI.Ped.CreatePed(PedHash.Poodle, new Vector3(player.Position.X, player.Position.Y - 3, player.Position.Z), player.Heading, dimension);
      Ped Peter19 = NAPI.Ped.CreatePed(PedHash.Pug, new Vector3(player.Position.X, player.Position.Y - 4, player.Position.Z), player.Heading, dimension);
      Ped Peter20 = NAPI.Ped.CreatePed(PedHash.Rabbit, new Vector3(player.Position.X, player.Position.Y - 5, player.Position.Z), player.Heading, dimension);
      Ped Peter21 = NAPI.Ped.CreatePed(PedHash.Rat, new Vector3(player.Position.X + 1, player.Position.Y + 1, player.Position.Z), player.Heading, dimension);
      Ped Peter22 = NAPI.Ped.CreatePed(PedHash.Retriever, new Vector3(player.Position.X + 2, player.Position.Y + 2, player.Position.Z), player.Heading, dimension);
      Ped Peter23 = NAPI.Ped.CreatePed(PedHash.Rhesus, new Vector3(player.Position.X + 3, player.Position.Y + 3, player.Position.Z), player.Heading, dimension);
      Ped Peter24 = NAPI.Ped.CreatePed(PedHash.Rottweiler, new Vector3(player.Position.X + 4, player.Position.Y + 4, player.Position.Z), player.Heading, dimension);
      Ped Peter25 = NAPI.Ped.CreatePed(PedHash.Seagull, new Vector3(player.Position.X + 5, player.Position.Y + 5, player.Position.Z + 2), player.Heading, dimension);
      Ped Peter26 = NAPI.Ped.CreatePed(PedHash.Shepherd, new Vector3(player.Position.X - 1, player.Position.Y - 1, player.Position.Z), player.Heading, dimension);
      Ped Peter27 = NAPI.Ped.CreatePed(PedHash.Stingray, new Vector3(player.Position.X - 2, player.Position.Y - 2, player.Position.Z), player.Heading, dimension);
      Ped Peter28 = NAPI.Ped.CreatePed(PedHash.Westy, new Vector3(player.Position.X - 3, player.Position.Y - 3, player.Position.Z), player.Heading, dimension);
      Ped Peter29 = NAPI.Ped.CreatePed(PedHash.MountainLion, new Vector3(player.Position.X - 4, player.Position.Y - 4, player.Position.Z), player.Heading, dimension);
      Ped Peter30 = NAPI.Ped.CreatePed(PedHash.FatCult01AFM, new Vector3(player.Position.X - 5, player.Position.Y - 5, player.Position.Z), player.Heading, dimension);
      Ped Peter31 = NAPI.Ped.CreatePed(PedHash.FatCult01AFM, new Vector3(player.Position.X + 1, player.Position.Y - 3, player.Position.Z), player.Heading, dimension);
      Ped Peter32 = NAPI.Ped.CreatePed(PedHash.FatCult01AFM, new Vector3(player.Position.X + 3, player.Position.Y - 1, player.Position.Z), player.Heading, dimension);
      Ped Peter33 = NAPI.Ped.CreatePed(PedHash.FatCult01AFM, new Vector3(player.Position.X - 1, player.Position.Y + 3, player.Position.Z), player.Heading, dimension);
      Ped Peter34 = NAPI.Ped.CreatePed(PedHash.Acult01AMM, new Vector3(player.Position.X - 3, player.Position.Y + 1, player.Position.Z), player.Heading, dimension);
      Ped Peter35 = NAPI.Ped.CreatePed(PedHash.Acult01AMM, new Vector3(player.Position.X + 5, player.Position.Y + 1, player.Position.Z), player.Heading, dimension);
      Ped Peter36 = NAPI.Ped.CreatePed(PedHash.Acult01AMO, new Vector3(player.Position.X + 1, player.Position.Y - 5, player.Position.Z), player.Heading, dimension);
      Ped Peter37 = NAPI.Ped.CreatePed(PedHash.Acult01AMO, new Vector3(player.Position.X + 4, player.Position.Y - 2, player.Position.Z), player.Heading, dimension);
      Ped Peter38 = NAPI.Ped.CreatePed(PedHash.Acult01AMY, new Vector3(player.Position.X - 5, player.Position.Y + 2, player.Position.Z), player.Heading, dimension);
      Ped Peter39 = NAPI.Ped.CreatePed(PedHash.Acult01AMY, new Vector3(player.Position.X - 4, player.Position.Y - 1, player.Position.Z), player.Heading, dimension);

      //Peter.freezePosition(true);
    }

    [Command("gotox", "~m~Benutzung: ~s~/gotox [X] [Y] [Z]")]
    public void CmdAdminGotoxyz(Player player, float x, float y, float z)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      if (player.IsInVehicle && player.VehicleSeat == 0) player.Vehicle.Position = new Vector3(x, y, z);
      else player.SafeTeleport(new Vector3(x, y, z));
    }

    [Command("slap", "~m~Benutzung: ~s~/slap [Spieler] (Höhe)")]
    public void CmdAdminSlap(Player player, string name, int wert = 5)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(name);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      Vector3 oldPos = target.Position;

      target.SafeTeleport(new Vector3(oldPos.X, oldPos.Y, oldPos.Z + wert));
      ChatService.SendMessage(player, "Du hast " + target.Name + " geslappt. Höhe: " + wert + "");
    }

    [Command("takeweapon", "~m~Benutzung: ~s~/takeweapon [Spieler]")]
    public void CmdAdminTakeWeapon(Player player, string name)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      Player target = PlayerService.GetPlayerByNameOrId(name);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }
      target.RemoveAllWeapons();
      ChatService.SendMessage(target, "~b~Deine Waffen wurden dir von " + player.Name + " (Admin) abgenommen");
      ChatService.SendMessage(player, "~b~Dem Spieler " + target.Name + " wurden erfolgreich alle Waffen abgenommen ");
    }

    [Command("tov", "~m~Benutzung: ~s~/tov [Fahrzeug ID]")]
    public void CmdAdminTov(Player player, int vehid)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Vehicle v = VehicleManager.GetVehicleFromId(vehid);
      if (v == null)
      {
        ChatService.ErrorMessage(player, "Dieses Fahrzeug existiert nicht");
        return;
      }

      player.SafeTeleport(v.Position.Add(new Vector3(0, 0, 2)));
    }

    [Command("ghv", "~m~Benutzung: ~s~/ghv [Fahrzeug ID]")]
    public void CmdAdminGhv(Player player, int vehid)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Vehicle v = VehicleManager.GetVehicleFromId(vehid);
      if (v == null)
      {
        ChatService.ErrorMessage(player, "Dieses Fahrzeug existiert nicht");
        return;
      }

      v.Position = player.Position;
      player.SafeTeleport(player.Position.Add(new Vector3(0, 0, 2)));
    }

    [Command("factionlist", "~m~Benutzung: ~s~/factionlist")]
    public void CmdAdminFactionlist(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      using (var dbContext = new DatabaseContext())
      {
        ChatService.SendMessage(player, "~m~__________ ~s~Fraktionen ~m~__________");
        foreach (Faction f in dbContext.Factions)
        {
          ChatService.SendMessage(player, f.Id.ToString().PadRight(3) + " | " + f.Name);
        }
      }
    }

    [Command("businesslist", "~m~Benutzung: ~s~/businesslist")]
    public void CmdAdminBusinessList(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      ChatService.SendMessage(player, "~m~__________ ~s~Businesses ~m~__________");
      foreach (BusinessBase b in BusinessManager.Businesses.OrderBy(b => b.Id))
      {
        ChatService.SendMessage(player, b.Id.ToString().PadRight(3) + " | " + b.Name + (b is CarDealerBusinessBase ? " | Autohaus" : ""));
      }
    }

    [Command("joblist", "~m~Benutzung: ~s~/joblist")]
    public void CmdAdminJoblist(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      ChatService.SendMessage(player, "~m~__________ ~s~Jobs ~m~__________");
      foreach (JobBase job in JobManager.GetJobs())
      {
        ChatService.SendMessage(player, job.Id.ToString().PadRight(3) + " | " + job.Name);
      }
    }

    [Command("respawnvehicle", "~m~Benutzung: ~s~/respawnvehicle (Db ID)", Alias = "rveh")]
    public void CmdAdminRespawnVehicle(Player player, int id = -1)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) //change back to Admin
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Vehicle veh = null;

      if (id == -1)
      {
        var nearestVeh = NAPI.Pools.GetAllVehicles().Where(v => v.Position.DistanceTo(player.Position) <= 5).FirstOrDefault();
        veh = nearestVeh;
      }
      else
      {
        veh = VehicleManager.GetVehicleFromId(id);
      }

      if (veh == null)
      {
        ChatService.ErrorMessage(player, "Es befindet sich kein Fahrzeug in deiner Nähe");
        return;
      }

      ServerVehicle serverVehicle = VehicleManager.GetServerVehicleFromVehicle(veh);

      if (serverVehicle == null)
      {
        ChatService.ErrorMessage(player, $"Dieses Fahrzeug kann nur gelöscht werden: ~m~/vdestroy {veh.Handle.Value}");
        return;
      }

      Vehicle newVeh = serverVehicle.Spawn(veh);
      newVeh.Repair();
      newVeh.Rotation = new Vector3(0, 0, serverVehicle.Heading);
    }

    [Command("rrespawnvehicle", "~m~Benutzung: ~s~/rrespawnvehicle [Radius]", Alias = "rrveh")]
    public void CmdAdminRangeRespawnVehicle(Player player, float radius)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (radius > 500)
      {
        ChatService.ErrorMessage(player, $"Der angegebene Radius ist zu hoch (Maximum: 500)");
        return;
      }

      List<Vehicle> vehiclesInRange = NAPI.Pools.GetAllVehicles().Where(v => v.Position.DistanceTo(player.Position) <= radius).ToList<Vehicle>();
      if (vehiclesInRange.Count == 0)
      {
        ChatService.ErrorMessage(player, $"Es befinden sich keine Fahrzeuge in deiner Nähe (Radius: {radius} SE)");
        return;
      }

      int respawnedVehicleCount = 0;
      foreach (Vehicle v in vehiclesInRange)
      {
        ServerVehicle serverVehicle = VehicleManager.GetServerVehicleFromVehicle(v);
        if (serverVehicle == null)
        {
          VehicleManager.DeleteVehicle(v);
          VehicleManager.DeleteVehicle(v.Trailer);
          continue;
        }

        Vehicle newVeh = serverVehicle.Spawn(v);

        respawnedVehicleCount++;
      }

      ChatService.BroadcastAdmin($"~g~Fahrzeug(e) respawnt: ~s~{player.Name} hat {respawnedVehicleCount} Fahrzeuge respawnt (Radius: {radius} SE).", AdminLevel.ADMIN);
    }

    [Command("sethp", "~m~Benutzung: ~s~/sethp [Spieler] (HP)")]
    public void CmdAdminSetHp(Player player, string name, int hp = 100)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(name);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      if (target.GetData<bool>("isDead") == true)
      {
        ChatService.ErrorMessage(player, "Dieser Spieler ist tot. Nutze /arevive");
        return;
      }

      target.SafeSetHealth(hp);
      ChatService.SendMessage(target, "~b~Deine HP wurden von " + player.Name + " auf " + hp + " gesetzt.");
      ChatService.SendMessage(player, "~b~Du hast die HP von " + target.Name + " auf " + hp + " gesetzt.");
    }

    [Command("clothes", "~m~Benutzung: ~s~/clothes [Spieler] [Component ID] [Drawable] (Textur)")]
    public void CmdAdminClothes(Player player, string name, int component, int drawable, int texture = 0)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(name);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      using (var dbContext = new DatabaseContext())
      {
        User user = target.GetUser(dbContext);
        bool duty = user.GetData<bool>("duty");
        CharacterCloth cloth = dbContext.CharacterClothes.Where(c => c.UserId == user.Id && c.SlotId == component && c.SlotType == 0 && c.Duty == duty).FirstOrDefault();
        if (cloth == null)
        {
          cloth = new CharacterCloth()
          {
            Duty = duty,
            ClothId = drawable,
            SlotId = component,
            SlotType = 0,
            Texture = texture,
            UserId = user.Id,
          };
          dbContext.CharacterClothes.Add(cloth);
        }
        else
        {
          cloth.ClothId = drawable;
          cloth.Texture = texture;
        }
        dbContext.SaveChanges();
        NAPI.Player.SetPlayerClothes(target, component, drawable, texture);
      }
    }

    [Command("props", "~m~Benutzung: ~s~/props [Spieler] [Component ID] [Drawable] (Textur)")]
    public void CmdAdminProps(Player player, string name, int slot, int component, int texture = 0)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(name);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      if (component == -1)
      {
        target.ClearAccessory(slot);
        return;
      }
      target.SetAccessories(slot, component, texture);
    }

    [Command("aunjail", "~m~Benutzung: ~s~/aunjail [Spieler]", GreedyArg = true)]
    public void CmdAdminAunjai(Player player, string targetname)
    {
      Player target = PlayerService.GetPlayerByNameOrId(targetname);
      if (target == null)
        return;

      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Jail.Release_Jail_Admin(player, target);
    }

    [Command("arevive", "~m~Benutzung: ~s~/arevive [Spieler]")]
    public void CmdAdminRevive(Player player, string name)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(name);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }
      if (!target.HasData("isDead") || !target.GetData<bool>("isDead"))
      {
        ChatService.ErrorMessage(player, "Der Spieler ist nicht tot");
        return;
      }
      target.TriggerEvent("onPlayerRevived");
      target.SendNotification("Du wurdest von Admin ~y~" + player.Name + "~s~ wiederbelebt.");

      MedicTask task = Medic.ReviveTasks.FirstOrDefault(t => t.Victim == player.Name);
      if (task != null)
      {
        ChatService.BroadcastFaction("~y~[MEDIC] ~w~Der Auftrag von " + target.Name + " wurde entfernt (Administrativ wiederbelebt)", new List<int>() { 2 });
      }

      target.SetData("isDead", false);
      using (var dbContext = new DatabaseContext())
      {
        User u;
        u = target.GetUser(dbContext);
        u.Dead = false;
        dbContext.SaveChanges();
      }
      target.SafeTeleport(target.Position, 0, true);
      target.SafeSetHealth(100);

      Medic.delReviveTask(target);
    }

    [Command("setap", "~m~Benutzung: ~s~/setap [Spieler] (Armor)")]
    public void CmdAdminSetAP(Player player, string name, int armor = 100)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(name);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      target.SafeSetArmor(armor);
      ChatService.SendMessage(target, "~b~Deine Rüstung wurde von " + player.Name + " auf " + armor + " gesetzt.");
      ChatService.SendMessage(player, "~b~Du hast die Rüstung von " + target.Name + " auf " + armor + " gesetzt.");
    }

    [Command("aclear", "~m~Benutzung: ~s~/aclear [Spieler] [Grund]", GreedyArg = true)]
    public void CmdFactionClear(Player player, string nameOrId, string reason)
    {
      User user = player.GetUser();
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(nameOrId);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      using (var dbContext = new DatabaseContext())
      {
        User targetUser = target.GetUser(dbContext);
        if (targetUser.Wanteds == 0)
        {
          ChatService.ErrorMessage(player, "Der Spieler hat keine Wanteds");
          return;
        }
        ChatService.SendMessage(target, "!{#8181E9}Deine Akte wurde vom Admin " + player.Name + " gelöscht. Grund: " + reason);
        ChatService.BroadcastFaction("!{#8181E9}HQ: Die Akte von " + target.Name + " wurde vom Admin " + player.Name + " gelöscht. Grund: " + reason + ".", new List<int>() { 1, 3 });

        target.TriggerEvent("jailTime", 0);
        targetUser.Wanteds = 0;

        targetUser.SetBlipAndNametagColor();

        dbContext.SaveChanges();
      }
    }

    [Command("adice", "~m~Benutzung: ~s~/adice [Zahl]")]
    public void CmdUserAdice(Player player, int number)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (!player.IsLoggedIn()) return;

      var peopleInRange = NAPI.Player.GetPlayersInRadiusOfPlayer(7, player);

      foreach (var managedPlayer in peopleInRange)
      {
        if (!managedPlayer.IsLoggedIn()) return;
        ChatService.SendMessage(managedPlayer, "* " + player.Name + " hat eine " + number + " gewürfelt.");
      }
    }

    [Command("veh", "~m~Benutzung: ~s~/veh [Fahrzeug] (Farbe 1) (Farbe 2)")]
    public void CmdAdminVeh(Player player, string hash, int color1 = 111, int color2 = 111)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      //TODO: Bestimmte Autos nur ab Adminlevel 1337, "normale Fahrzeuge" schon ab Adminlevel 3.
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (player.IsInVehicle) // Man darf keine Autos erstellen, wenn man selbst in einem sitzt (verhindert Bugs)
      {
        ChatService.ErrorMessage(player, "Du sitzt momentan schon in einem Fahrzeug");
        return;
      }

      if (!uint.TryParse(hash, out uint uHash))
        uHash = NAPI.Util.GetHashKey(hash);

      if (!VehicleManager.IsValidHash(uHash))
      {
        ChatService.ErrorMessage(player, "Dieses Fahrzeug existiert nicht");
        return;
      }

      Vehicle v = NAPI.Vehicle.CreateVehicle(uHash, player.Position, player.Heading, color1, color2, engine: true);
      VehicleStreaming.SetEngineState(v, true);
      VehicleStreaming.SetLockStatus(v, false);
      player.SetIntoVehicle(v.Handle, 0);
      player.SetIntoVehicle(v.Handle, 0);
    }

    [Command("fv", "~m~Benutzung: ~s~/fv", Alias = "vfix")]
    public void CmdAdminFixveh(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (!player.IsInVehicle)
      {
        ChatService.ErrorMessage(player, "Du sitzt momentan nicht in einem Fahrzeug");
        return;
      }
      player.Vehicle.Repair();
      ChatService.SendMessage(player, "Fahrzeug repariert");
    }

    [Command("vdestroy", "~m~Benutzung: ~s~/vdestroy (ID)")]
    public void CmdAdminVdestroy(Player player, int vid = -1)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Vehicle targetVeh;

      if (vid == -1)
      {
        if (!player.IsInVehicle)
        {
          ChatService.SendMessage(player, "~m~Benutzung: ~s~/vdestroy (ID)");
          return;
        }
        targetVeh = player.Vehicle;
      }
      else
      {
        targetVeh = VehicleManager.GetVehicleFromId(vid);
        if (targetVeh == null)
        {
          ChatService.ErrorMessage(player, "Dieses Fahrzeug existiert nicht");
          return;
        }
      }

      ServerVehicle veh = VehicleManager.GetServerVehicleFromVehicle(targetVeh);

      if (veh != null)
      {
        ChatService.ErrorMessage(player, "Dieses Fahrzeug wird von einem Server-System benutzt: ~m~" + veh.GetType().Name);
        return;
      }

      VehicleManager.DeleteVehicle(targetVeh);
      targetVeh.Trailer?.Delete();
    }

    [Command("vcolor", "~m~Benutzung: ~s~/vcolor [Farb-ID1] [Farb-ID2]")]
    public void CmdAdminColor(Player player, int color1, int color2)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (!player.IsInVehicle)
      {
        ChatService.ErrorMessage(player, "Du sitzt momentan in keinem Fahrzeug");
        return;
      }

      player.Vehicle.PrimaryColor = color1;
      player.Vehicle.SecondaryColor = color2;
      ChatService.SendMessage(player, "Farb-ID1 " + color1 + ", Farb-ID2 " + color2 + "");
    }

    [Command("giveweapon", "~m~Benutzung: ~s~/giveweapon [Spieler] [Waffe] [Munition]")]
    public void CmdAdminGiveweapon(Player player, string name, string hash, int ammo)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (ammo <= 0)
      {
        ChatService.ErrorMessage(player, "Es muss mindestens 1 Munition vergeben werden");
        return;
      }

      hash = hash.ToLower();

      Player target = PlayerService.GetPlayerByNameOrId(name);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      if (!uint.TryParse(hash, out uint uHash))
      {
        if (hash.Contains("mk2") && !hash.Contains("_mk2")) hash = hash.Replace("mk2", "_mk2");
        uHash = NAPI.Util.GetHashKey($"weapon_{hash}");
      }

      if (!WeaponManager.IsValidHash(uHash))
      {
        ChatService.ErrorMessage(player, "Diese Waffe existiert nicht");
        return;
      }

      target.GiveWeapon((WeaponHash)uHash, ammo);
      ChatService.SendMessage(target, "~b~Du hast von " + player.Name + " eine/n " + hash + " mit einer Munition von " + ammo + " erhalten.");
      ChatService.SendMessage(player, "~b~Du hast " + target.Name + " eine/n " + hash + " mit einer Munition von " + ammo + " gegeben.");
    }

    [Command("aneon", "~m~Benutzung: ~s~/aneon [R][G][B]")]
    public void CmdAdminNeon(Player player, int r, int g, int b)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (!player.IsInVehicle)
      {
        ChatService.ErrorMessage(player, "Du sitzt momentan nicht in einem Fahrzeug");
        return;
      }

      Vehicle veh = NAPI.Player.GetPlayerVehicle(player);
      NAPI.Vehicle.SetVehicleNeonColor(veh, r, g, b);
      NAPI.Vehicle.SetVehicleNeonState(veh, true);
    }

    [Command("vehsmoke", "~m~Benutzung: ~s~/vehsmoke [R][G][B]")]
    public void CmdAdminVehSmoke(Player player, int r, int g, int b)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (!player.IsInVehicle)
      {
        ChatService.ErrorMessage(player, "Du sitzt momentan nicht in einem Fahrzeug");
        return;
      }

      Vehicle veh = NAPI.Player.GetPlayerVehicle(player);
      NAPI.Vehicle.SetVehicleTyreSmokeColor(veh, new Color(r, g, b));
    }

    [Command("spectate", "~m~Benutzung: ~s~/spectate [NAME/ID]", Alias = "spec")]
    public void CmdAdminSpectate(Player player, string targetname = null)
    {
      User user = player.GetUser();
      if (!user.IsAdmin(AdminLevel.ADMIN))
      {
        ChatService.NotAuthorized(player);
        return;
      }
      Player target;

      bool currentStatus = player.GetData<bool>("adminUnshow");

      if (targetname != null)
      {
        target = PlayerService.GetPlayerByNameOrId(targetname);
        if (target == null || !target.IsLoggedIn())
        {
          ChatService.PlayerNotFound(player);
          return;
        }

        if (target.Name == player.Name)
        {
          ChatService.ErrorMessage(player, "Du kannst dich nicht selbst spectaten");
          return;
        }

        if (!currentStatus)
        {
          currentStatus = !currentStatus;
          player.SetData("adminUnshow", currentStatus);
        }
        player.TriggerEvent("toggleAdminUnshowMode", currentStatus);
        player.SetData<Vector3>("specPosition", player.Position);

        player.SafeTeleport(target.Position);

        NAPI.Task.Run(() =>
        {
          player.TriggerEvent("SERVER:ADMIN_SPECTATE", target);
        }, 100);
      }
      else
      {
        currentStatus = !currentStatus;
        player.SetData("adminUnshow", currentStatus);
        player.TriggerEvent("SERVER:ADMIN_STOP_SPECTATE");
        player.TriggerEvent("toggleAdminUnshowMode", currentStatus);
        player.SafeTeleport(player.GetData<Vector3>("specPosition"));
      }
      user.SetBlipAndNametagColor();
    }

    [Command("aunshow", "~m~Benutzung:~s~ /aunshow")]
    public void CmdAdminUnshow(Player player)
    {
      User user = player.GetUser();
      if (!user.IsAdmin(AdminLevel.HEADADMIN))
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (!player.IsTSupport())
      {
        ChatService.ErrorMessage(player, "Du bist nicht im T-Support");
        return;
      }

      bool currentStatus = player.GetData<bool>("adminUnshow");
      currentStatus = !currentStatus;
      player.SetData("adminUnshow", currentStatus);
      player.TriggerEvent("toggleAdminUnshowMode", currentStatus);

      user.SetBlipAndNametagColor();

      if (currentStatus)
      {
        ChatService.SendMessage(player, "~b~[ADMIN]~s~ Du bist nun Unshow");
      }
      else
      {
        ChatService.SendMessage(player, "~b~[ADMIN]~s~ Du bist nun nicht mehr Unshow");
      }
    }

    #endregion Admin

    #region ALevel1337

    /*NUR ZUM TESTEN
   [Command("fakedeath", "~m~Benutzung:~s~ /fakedeath")]
   public void CmdAdmFakeDeath(Player player)
   {
     if (!player.GetUser()?.IsAdmin(AdminLevel.PROJEKTLEITUNG) ?? true)
     {
       ChatService.NotAuthorized(player);
       return;
     }
     MedicTask reviveTask = new MedicTask()
     {
       Victim = player.Name,
       Position = player.Position,
       CauseOfDeath = "FAKE",
       Caller = null,
       Description = "Gestorben",
       Time = DateTime.Now,
       Type = MedicTaskType.REVIVE,
       MedicName = "none"
     };
     Medic.AddTaskToList(reviveTask);
   }*/

    [Command("setblipcolor", "~m~Benutzung:~s~ /setblipcolor [ID]")]
    public void CmdAdmSetBlipColor(Player player, int blipId)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.PROJEKTLEITUNG) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      player.SetSharedData("blipColor", blipId);
    }

    [Command("setsvar", "~m~Benutzung:~s~ /setsvar [ID] [WERT]")]
    public void CmdAdmSetSvar(Player player, int varId, int varValue)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.PROJEKTLEITUNG) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      Managers.SVarManager.ChangeSVarValue(player, varId, varValue);
    }

    [Command("createturf", "~m~Benutzung:~s~ /createturf [radius]")]
    public void CmdAdmCreateTurf(Player player, float option)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      player.TriggerEvent("ADMIN:CreateTurf", JsonConvert.SerializeObject(option));
    }

    [Command("setturf", "~m~Benutzung:~s~ /setturf (Name)")]
    public void CmdAdmSetTurf(Player player, string name)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      player.TriggerEvent("ADMIN:SetTurf", name);
    }

    [Command("cancleturf", "~m~Benutzung:~s~ /cancleturf")]
    public void CmdAdmCancleTurf(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      Gangwar.Gangwar.loadPlayer(player);
    }

    [Command("reloadturfs", "~m~Benutzung:~s~ /ReloadTurfs")]
    public void CmdAdmReloadTurf(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      Gangwar.Gangwar.loadTurfs();
      Gangwar.Gangwar.loadTurfs_ToAllPlayers();
    }

    [Command("deleteturf", "~m~Benutzung:~s~ /DeleteTurfs")]
    public void CmdAdmDeleteTurf(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      player.TriggerEvent("ADMIN:DeleteTurf");
    }

    [Command("setturfpoint", "~m~Benutzung:~s~ /setturfpoint")]
    public void CmdAdmSetTurfPoint(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      player.TriggerEvent("ADMIN:Turf_CreateLeaderBlip");
    }

    [Command("removewarn", "~m~Benutzung: ~s~/removewarn [Player] [Grund]", GreedyArg = true)]
    public void CmdAdminRemovewarn(Player player, string targetname, string reason)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(targetname);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      string targetPlayername = NAPI.Player.GetPlayerName(target);
      string adminPlayername = NAPI.Player.GetPlayerName(player);

      using (var dbContext = new DatabaseContext())
      {
        User userwarn = player.GetUser(dbContext);
        if (userwarn.warn == 0)
        {
          player.SendChatMessage("~r~WARNINFO: ~w~Der User hat bereits 0 Warns");
          return;
        }
        userwarn.warn--;
        dbContext.SaveChanges();
      }
      ChatService.SendMessage(target, "~r~WARNINFO: ~w~Dir wurde von " + adminPlayername + " ein Warn entfernt: " + reason);

      ChatService.Broadcast("~y~INFO: ~w~" + targetPlayername + " wurde von " + player.GetUser().AdminLevel.GetName() + " " + adminPlayername + " ein Warn entfernt: " + reason);
    }

    [Command("setskill", "~m~Benutzung: ~s~/setskill [Playerid] [Bus/Pilot] [Menge]")]
    public void CmdAdminSetSkill(Player player, string name, string Skill, int SkillLevel)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      Player target = PlayerService.GetPlayerByNameOrId(name);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }
      if (SkillLevel < 0)
      {
        ChatService.SendMessage(player, "~r~Skilllevel kann nicht unter 0 sein");
        return;
      }
      switch (Skill.ToLower())
      {
        case "bus":
          {
            using (var dbContext = new DatabaseContext())
            {
              target.GetUser(dbContext).BusSkill = SkillLevel;
              dbContext.SaveChanges();
            }
            break;
          }
        case "pilot":
          {
            using (var dbContext = new DatabaseContext())
            {
              target.GetUser(dbContext).PilotSkill = SkillLevel;
              dbContext.SaveChanges();
            }
          }
          break;
      }
      ChatService.SendMessage(player, $"~w~Du hast den ~y~{Skill}-Skill ~w~von ~y~{target.Name} ~w~auf ~g~{SkillLevel} ~w~gesetzt.");
      ChatService.SendMessage(target, $"~w~{player.Name} hat deinen ~y~{Skill}-Skill ~w~auf ~g~{SkillLevel} ~w~gesetzt.");
    }

    [Command("setjob", "~m~Benutzung: ~s~/setjob [Playerid] [JobID 1=Taxifahrer, 2=Müllmann, 3=Pilot, 4=Busfahrer]")]
    public void CmdAdminSetJob(Player player, string name, int JobID)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      Player target = PlayerService.GetPlayerByNameOrId(name);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }
      if (JobManager.GetJob(JobID) == null)
      {
        ChatService.ErrorMessage(player, "Dieser job existiert nicht");
        return;
      }
      using (var dbContext = new DatabaseContext())
      {
        target.GetUser(dbContext).JobId = JobID;
        dbContext.SaveChanges();
      }
      ChatService.SendMessage(player, $"~w~Du hast die ~y~JobID ~w~von ~y~{target.Name} ~w~auf ~g~{JobID} ~w~gesetzt.");
      ChatService.SendMessage(target, $"~w~{player.Name} hat deine ~y~JobID ~w~auf ~g~{JobID} ~w~gesetzt.");
    }

    [Command("rgiveweapon", "~m~Benutzung: ~s~/rgiveweapon [Radius] [Waffe] [Munition]")]
    public void CmdAdminRangeGiveWeapon(Player player, float radius, string weapon, int munition)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      weapon = weapon.ToLower();

      if (!uint.TryParse(weapon, out uint uHash))
      {
        if (weapon.Contains("mk2") && !weapon.Contains("_mk2")) weapon = weapon.Replace("mk2", "_mk2");
        uHash = NAPI.Util.GetHashKey($"weapon_{weapon}");
      }

      if (!WeaponManager.IsValidHash(uHash))
      {
        ChatService.ErrorMessage(player, "Diese Waffe existiert nicht");
        return;
      }

      WeaponHash weaponHash = (WeaponHash)uHash;

      var peopleInRange = NAPI.Player.GetPlayersInRadiusOfPlayer(radius, player);

      foreach (var managedPlayer in peopleInRange)
      {
        if (!managedPlayer.IsLoggedIn()) return;
        managedPlayer.GiveWeapon(weaponHash, munition);
        ChatService.SendMessage(managedPlayer, "~b~Admin " + player.Name + " hat im Radius von " + radius + " eine/n " + weapon + " mit " + munition + " Munition vergeben.");
      }
      ChatService.SendMessage(player, "~b~Du hast " + peopleInRange.Count + " Spielern eine " + weapon + " mit " + munition + " Munition gegeben");
    }

    [Command("rsetap", "~m~Benutzung: ~s~/rsetap [Radius] (Armor)")]
    public void CmdAdminRangeSetAP(Player player, float radius, int Armor = 100)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      var peopleInRange = NAPI.Player.GetPlayersInRadiusOfPlayer(radius, player);

      foreach (var managedPlayer in peopleInRange)
      {
        if (!managedPlayer.IsLoggedIn()) return;
        managedPlayer.SafeSetArmor(Armor);
        ChatService.SendMessage(managedPlayer, "~b~Admin " + player.Name + " hat im Radius von " + radius + " die Rüstung auf " + Armor + " gesetzt.");
      }
      ChatService.SendMessage(player, "~b~Die Rüstung von " + peopleInRange.Count + " Spielern wurde auf " + Armor + " gesetzt.");
    }

    [Command("rsethp", "~m~Benutzung: ~s~/rsethp [Radius] (Leben)")]
    public void CmdAdminRangeSetHP(Player player, float radius, int hp = 100)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      var peopleInRange = NAPI.Player.GetPlayersInRadiusOfPlayer(radius, player);

      foreach (var managedPlayer in peopleInRange)
      {
        if (!managedPlayer.IsLoggedIn() || managedPlayer.GetData<bool>("isDead")) continue;
        managedPlayer.SafeSetHealth(hp);
        ChatService.SendMessage(managedPlayer, "~b~Admin " + player.Name + " hat im Radius von " + radius + " die HP auf " + hp + " gesetzt.");
      }
      ChatService.SendMessage(player, "~b~Das Leben von " + peopleInRange.Count + " Spielern wurde auf " + hp + " gesetzt.");
    }

    [Command("rsetwage", "~m~Benutzung: ~s~/rsetwage [Radius] (Verdienst)")]
    public void CmdAdminRangeSetWage(Player player, float radius, int wage)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      var peopleInRange = NAPI.Player.GetPlayersInRadiusOfPlayer(radius, player);

      using (var dbContext = new DatabaseContext())
      {
        foreach (var managedPlayer in peopleInRange)
        {
          if (!managedPlayer.IsLoggedIn()) return;
          managedPlayer.GetUser(dbContext).Wage += wage;

          ChatService.SendMessage(managedPlayer, "~b~Admin " + player.Name + " hat im Radius von " + radius + " den Verdienst um $" + wage + " erhöht.");
          dbContext.SaveChanges();
        }
      }
      ChatService.SendMessage(player, "~b~Der Verdienst von " + peopleInRange.Count + " Spielern wurde um $" + wage + " erhöht.");
    }

    [Command("setweather", "~m~Benutzung: ~s~/setweather [Wetter]")]
    public void CmdAdminSetweather(Player player, string weather)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Weather weatherBefore = World.WeatherSync.Weather;
      World.WeatherSync.SetWeather(weather);
      Weather weatherAfter = World.WeatherSync.Weather;

      ChatService.SendMessage(player, "~w~Wetter geändert: " + weatherAfter);

      if (!weatherBefore.Equals(weatherAfter))
      {
        NAPI.Notification.SendNotificationToAll("Das Wetter wurde von ~g~" + player.Name + " ~s~auf ~g~" + weatherAfter + "~s~ geändert.", true);
      }
    }

    [Command("settime", "~m~Benutzung: ~s~/settime [Stunde] (Minuten) (Sekunden)")]
    public void CmdAdminSetTime(Player player, int hour, int min = 0, int sec = 0)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (hour > 23 || min > 59 || sec > 59)
      {
        ChatService.ErrorMessage(player, "Es wurde eine ungültige Zeit eingegeben");
        return;
      }

      if (hour == -1)
      {
        ChatService.SendMessage(player, "Es wird nun wieder die Echtzeit genutzt.");
        TimeManager.StartTimeManager();
        return;
      }
      string broadcastMsg = $"Serverzeit wurde auf ~g~{hour:D2}:{min:D2}:{sec:D2} ~s~gesetzt!";
      NAPI.Notification.SendNotificationToAll(broadcastMsg);
      TimeManager.PauseTimeManager(new TimeSpan(hour, min, sec));
      NAPI.World.SetTime(hour, min, sec);
      return;
    }


    [Command("showtuningmenu", "~m~Benutzung: ~s~/showtuningmenu", Alias = "stm")]
    public void CmdAdminShowtuningmenu(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (!player.IsInVehicle || player.VehicleSeat != 0)
      {
        ChatService.ErrorMessage(player, "Du musst Fahrer sein, um das Menü zu öffnen");
        return;
      }
      else
      {
        player.TriggerEvent("showTuningMenu", true);
      }
    }

    [Command("vmod", "~m~Benutzung: ~s~/vmod [Slot] [Mod ID]")]
    public void CmdAdminVmod(Player player, int slot, int mod)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (!player.IsInVehicle)
      {
        ChatService.ErrorMessage(player, "Du sitzt momentan nicht in einem Fahrzeug");
        return;
      }

      player.Vehicle.SetMod(slot, mod);
    }

    [Command("vlivery", "~m~Benutzung: ~s~/vlivery [Livery]")]
    public void CmdAdminVlivery(Player player, int livery)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (!player.IsInVehicle)
      {
        ChatService.ErrorMessage(player, "Du sitzt momentan nicht in einem Fahrzeug");
        return;
      }

      Vehicle playerVeh = player.Vehicle;

      playerVeh.Livery = livery;

      using (var dbContext = new DatabaseContext())
      {
        ServerVehicle serverVeh = VehicleManager.GetServerVehicleFromVehicle(playerVeh, dbContext);
        if (serverVeh != null)
        {
          serverVeh.Livery = livery;
          dbContext.SaveChanges();
        }
      }
    }

    [Command("wepmod", "~m~Benutzung: ~s~/wepmod [Variable]")]
    public void CmdWeaponModifier(Player player, float modifier)
    {
      player.SendChatMessage("Modifier steht auf" + modifier);
      player.TriggerEvent("SERVER:WeaponModifier2", player, modifier, 1);
    }

    [Command("wepmmod", "~m~Benutzung: ~s~/wepmmod [Variable]")]
    public void CmdWeaponMeeleModifier(Player player, float modifier)
    {
      player.SendChatMessage("MeeleModifier steht auf" + modifier);
      player.TriggerEvent("SERVER:WeaponModifier2", player, 1, modifier);
    }

    [Command("gotocp", "~m~Benutzung: ~s~/gotocp")]
    public void CmdAdminGotocp(Player admin)
    {
      admin.TriggerEvent("getCP");
    }

    [RemoteEvent("sendCP")]
    public void sendCPfunc(Player user, int x, int y, int z)
    {
      Vector3 pos = new Vector3(x, y, z);
      user.SafeTeleport(pos);
    }

    [Command("sethandmoney", "~m~Benutzung: ~s~/sethandmoney [Name/ID] [Menge]")]
    public void CmdAdminSetUserHandMoney(Player admin, string targetname, int amount)
    {
      if (!admin.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(admin);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(targetname);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(target);
        return;
      }
      using (var context = new DatabaseContext())
      {
        var user = target.GetUser(context);
        user.Handmoney = amount;
        context.SaveChanges();
        //target.TriggerEvent("SERVER:SET_HANDMONEY", amount);
      }
      ChatService.SendMessage(admin, "~b~[ADMIN]~s~ Du hast das Handgeld von " + target.Name + " auf ~g~$" + amount + "~s~ gesetzt.");
      ChatService.SendMessage(target, "~b~[ADMIN]~s~ Dein Handgeld wurde von Admin " + admin.Name + " auf ~g~$" + amount + "~s~ gesetzt.");
    }

    [Command("givehandmoney", "~m~Benutzung: ~s~/givehandmoney [Name/ID] [Menge]")]
    public void CmdAdminGiveUserHandMoney(Player admin, string targetname, int amount)
    {
      if (!admin.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(admin);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(targetname);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(target);
        return;
      }
      using (var context = new DatabaseContext())
      {
        var user = target.GetUser(context);
        user.Handmoney += amount;
        context.SaveChanges();
        //target.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
      }
      ChatService.SendMessage(admin, "~b~[ADMIN]~s~ Du hast " + target.Name + " ~g~$" + amount + "~s~ auf die Hand gegeben.");
      ChatService.SendMessage(target, "~b~[ADMIN]~s~ Admin " + admin.Name + " hat dir ~g~$" + amount + "~s~ auf die Hand gegeben.");
    }

    [Command("quicksavemode", "~m~Benutzung: ~s~/quicksavemode [Modus]: ~g~blip, ~g~atm")]
    public void CmdAdminSetQuickSaveMode(Player player, string mode)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      player.SetData("quicksavemode", mode.ToLower());
    }

    [Command("giveitem", "~m~Benutzung: ~s~/giveitem [Target] [Item ID] [Anzahl]")]
    public void CmdAdminGiveItem(Player player, string targetname, int itemId, int amount)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(targetname);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      var invWeight = 0;

      using (var context = new DatabaseContext())
      {
        List<UserItem> userItems = context.UserItems.ToList().FindAll(i => i.UserId == target.GetUser().Id);
        foreach (var uItem in userItems)
        {
          invWeight += uItem.Amount * InventoryManager.GetItemById(uItem.ItemId).Gewicht;
        }
      }

      if (invWeight + (amount * InventoryManager.GetItemById(itemId).Gewicht) > 40000)
      {
        ChatService.SendMessage(player, "~y~" + target.Name + " ~s~hat nicht mehr genug Platz in seinem Inventar.");
      }
      else
      {
        UserItem item = new UserItem() { ItemId = itemId, UserId = target.GetUser().Id, Amount = amount };
        InventoryManager.AddItemToInventory(target, item.ItemId, item.Amount);
        ChatService.SendMessage(player, "~b~[ADMIN]~s~ Du hast " + target.Name + " ~g~" + amount + "~s~ mal das Item gegeben.");
      }
    }

    [Command("setshopitem", "~m~Benutzung: ~s~/setshopitem [Item ID]")]
    public void CmdAdminSetItemInShop(Player player, int itemId)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      IItem item = InventoryManager.GetItemById(itemId);
      if (item is null)
      {
        ChatService.ErrorMessage(player, "Item existiert nicht");
        return;
      }

      ItemshopPoint nearestItemShopPoint = PositionManager.itemshopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5);

      if (nearestItemShopPoint is null)
      {
        ChatService.ErrorMessage(player, "Du bist nicht an einem Item Shop");
        return;
      }

      using var dbContext = new DatabaseContext();

      if (dbContext.ShopItems.Where(i => i.ShopId == nearestItemShopPoint.itemShop.id && i.ItemId == item.Id).FirstOrDefault() != null)
      {
        ChatService.ErrorMessage(player, "Item ist bereits im Shop");
        return;
      }

      ShopItem shopItem = new ShopItem
      {
        ShopId = nearestItemShopPoint.itemShop.id,
        ItemId = item.Id,
        Amount = 20,
        Price = item.Price
      };

      dbContext.ShopItems.Add(shopItem);
      dbContext.SaveChanges();

      nearestItemShopPoint.itemShop.LoadItems();
    }

    [Command("rmshopitem", "~m~Benutzung: ~s~/rmshopitem [Item ID]")]
    public void CmdAdminRemoveItemInShop(Player player, int itemId)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      IItem item = InventoryManager.GetItemById(itemId);
      if (item is null)
      {
        ChatService.ErrorMessage(player, "Item existiert nicht");
        return;
      }

      ItemshopPoint nearestItemShopPoint = PositionManager.itemshopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5);

      if (nearestItemShopPoint is null)
      {
        ChatService.ErrorMessage(player, "Du bist nicht an einem Item Shop");
        return;
      }

      using var dbContext = new DatabaseContext();

      ShopItem shopItem = dbContext.ShopItems.Where(i => i.ShopId == nearestItemShopPoint.itemShop.id && i.ItemId == item.Id).FirstOrDefault();

      if (shopItem is null)
      {
        return;
      }

      dbContext.ShopItems.Remove(shopItem);
      dbContext.SaveChanges();

      nearestItemShopPoint.itemShop.LoadItems();
    }

    [Command("inventory", "~m~Benutzung: ~s~/inventory [Spieler]")]
    public void CmdAdminGiveItem(Player player, string targetname)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(targetname);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      var user = target.GetUser();

      InventoryManager.GetUserItemsAsAdmin(player, user);
    }

    [Command("editmode", "~m~Benutzung: ~s~/editmode")]
    public void CmdAdminToggleEditMode(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (player.GetData<bool>("editmode") == false)
      {
        player.SetData("editmode", true);
        player.SendNotification("Edit-Mode ~g~aktiviert");
        player.TriggerEvent("toggleEditMode", true);
      }
      else
      {
        player.SetData("editmode", false);
        player.SendNotification("Edit-Mode ~r~deaktiviert");
        player.TriggerEvent("toggleEditMode", false);
      }
    }

    [Command("setbliptemplate", "~m~Benutzung: ~s~/setbliptemplate [byte COLOR] [byte ALPHA] [bool SHORTRANGE] [uint SPRITE] [float SCALE] [string NAME]", GreedyArg = true)]
    public void CmdAdminSetBlipTemplate(Player player, byte color, byte alpha, bool shortRange, uint sprite, float scale, string name)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      TempBlip newTempBlip = new TempBlip()
      {
        Color = color,
        Name = name,
        Transparency = alpha,
        ShortRange = shortRange,
        Sprite = sprite,
        Scale = scale,
      };

      NAPI.Data.SetWorldData("blipTemplate", newTempBlip);
    }

    [Command("ipl", "~m~Benutzung: ~s~/ipl [Load / Remove] [Name]")]
    public void CmdAdminIpl(Player player, string option, string name)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      option = option.ToLower();

      if (option == "load")
      {
        NAPI.World.RequestIpl(name);
        ChatService.SendMessage(player, "~g~Das IPL ~s~" + name + " ~g~wurde erfolgreich geladen");
      }
      else if (option == "remove")
      {
        NAPI.World.RemoveIpl(name);
        ChatService.SendMessage(player, "~g~Das IPL ~s~" + name + " ~g~wurde erfolgreich entladen");
      }
      else
      {
        ChatService.SendMessage(player, "~m~Benutzung: ~s~/ipl [Load / Remove] [Name]");
      }
    }

    [Command("freekh", "~m~Benutzung: ~s~/freekh (Radius)")]
    public void CmdAdminFreekh(Player player, float radius = -1)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      var peopleInRange = radius == -1 ? NAPI.Pools.GetAllPlayers() : NAPI.Player.GetPlayersInRadiusOfPlayer(radius, player);
      int playerRevided = 0;

      string toPlayerChat = "~b~Admin " + player.Name + " hat alle Spieler wiederbelebt";
      string toPlayerNotification = "Du wurdest von Admin ~y~" + player.Name + "~s~ wiederbelebt.";

      foreach (var managedPlayer in peopleInRange)
      {
        if (!managedPlayer.IsLoggedIn()) continue;
        if (!managedPlayer.HasData("isDead") || managedPlayer.GetData<bool>("isDead") == false) continue;
        playerRevided++;

        managedPlayer.TriggerEvent("onPlayerRevived");
        managedPlayer.SetData("isDead", false);
        using (var dbContext = new DatabaseContext())
        {
          User u;
          u = managedPlayer.GetUser(dbContext);
          u.Dead = false;
          dbContext.SaveChanges();
        }
        managedPlayer.SendNotification(toPlayerNotification);
        ChatService.SendMessage(managedPlayer, toPlayerChat);

        managedPlayer.SafeTeleport(managedPlayer.Position, 0, true);
        managedPlayer.SafeSetHealth(100);

        Medic.delReviveTask(managedPlayer);
      }

      ChatService.SendMessage(player, "~b~Du hast " + playerRevided + " Spieler wiederbelebt.");
    }

    [Command("ainvite", "~m~Benutzung: ~s~/ainvite [Name] [Fraktion]")]
    public void CmdAdminAinvite(Player player, string name, int faction)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(name);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      using (var dbContext = new DatabaseContext())
      {
        Faction f = dbContext.Factions.FirstOrDefault(x => x.Id == faction);
        if (f == null && faction != 0)
        {
          ChatService.ErrorMessage(player, "Diese Fraktion existiert nicht (Liste: ~m~/factionlist~s~)");
          return;
        }

        User u = target.GetUser(dbContext);

        FactionHelper.ResetPlayer(target, u, dbContext);

        if (faction != 0)
        {
          u.FactionId = f.Id;
          u.FactionRankId = dbContext.FactionRanks.
              OrderBy(x => x.Order)
              .FirstOrDefault(r => r.FactionId == f.Id)?.Id ?? null;

          ChatService.SendMessage(player, "~b~[ADMIN]~s~ Du hast hast den Spieler ~y~" + target.Name + "~s~ administrativ in die Fraktion ~o~" + f.Name + "~s~ eingeladen.");
          ChatService.SendMessage(target, "~b~[ADMIN]~s~ Du wurdest von ~y~" + player.Name + "~s~ administrativ in die Fraktion ~o~" + f.Name + "~s~ eingeladen.");
        }
        else
        {
          u.FactionId = null;
          u.FactionRankId = null;
          ChatService.SendMessage(player, "~b~[ADMIN]~s~ Du hast hast den Spieler ~y~" + target.Name + "~s~ administrativ aus seiner Fraktion geworfen.");
          ChatService.SendMessage(target, "~b~[ADMIN]~s~ Du wurdest von ~y~" + player.Name + "~s~ administrativ aus deiner Fraktion geworfen.");
        }

        u.FactionLeader = false;
        u.SetBlipAndNametagColor();
        dbContext.SaveChanges();
      }
    }

    [Command("makeleader", "~m~Benutzung: ~s~/makeleader [Name] [Fraktion]")]
    public void CmdAdminMakeleader(Player player, string name, int faction)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(name);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      using (var dbContext = new DatabaseContext())
      {
        Faction f = dbContext.Factions.FirstOrDefault(x => x.Id == faction);
        if (f == null)
        {
          ChatService.ErrorMessage(player, "Diese Fraktion existiert nicht (Liste: ~m~/factionlist~s~)");
          return;
        }

        User u = target.GetUser(dbContext);

        FactionHelper.ResetPlayer(target, u, dbContext);

        u.FactionId = f.Id;
        u.FactionRankId = dbContext.FactionRanks.
            OrderByDescending(x => x.Order)
            .FirstOrDefault(r => r.FactionId == f.Id)?.Id ?? null;
        u.FactionLeader = true;

        ChatService.SendMessage(player, "~b~[ADMIN]~s~ Du hast hast den Spieler ~y~" + target.Name + "~s~ zum Leader der Fraktion ~o~" + f.Name + "~s~ ernannt.");
        ChatService.SendMessage(target, "~b~[ADMIN]~s~ Du wurdest von ~y~" + player.Name + "~s~ zum Leader der Fraktion ~o~" + f.Name + "~s~ ernannt.");

        u.SetBlipAndNametagColor();
        dbContext.SaveChanges();
      }
    }

    [Command("save", "~m~Benutzung: ~s~/save [Typ = ~g~Blip~s~, ~g~Goto (X)~s~, ~r~Marker~s~, ~r~Ped~s~, ~r~Pickup~s~, ~r~TextLabel~s~, ~g~Vehicle~s~, ~g~FVehicle~s~, ~g~SVehicle (X)~s~, ~g~JVehicle (X)~s~, ~g~SchoolVehicle (X)~s~, ~g~NoobVehicle~s~, ~g~Location~s~] (Weitere Angaben) = (X)", GreedyArg = true)]
    public void CmdAdminSave(Player player, string typ, string option1 = null, string option2 = null)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      switch (typ.ToLower())
      {
        case "blip":
          player.TriggerEvent("saveBlip");
          break;

        case "goto":
          if (option1 == null)
          {
            ChatService.SendMessage(player, "Für Goto musst du einen dritten Parameter angeben. Beispiel: Ort des Goto-Punktes.");
            return;
          }
          else
          {
            using (var dbContext = new DatabaseContext())
            {
              GotoPoint p = dbContext.GotoPoints.FirstOrDefault(x => x.Description == option1);
              if (p == null)
              {
                SaveManager.SaveGotoPoint(player, option1);
                player.SendNotification("Goto-Punkt ~g~" + option1 + "~s~ gespeichert.", true);
              }
              else
              {
                ChatService.SendMessage(player, "Einen Goto-Punkt mit dieser Bezeichnung gibt es schon!");
              }
            }
          }

          break;

        case "vehicle":
          if (player.IsInVehicle)
          {
            Vehicle vehicle = player.Vehicle;
            int playerSeat = player.VehicleSeat;
            vehicle = SaveManager.SaveVehicleData(vehicle, (VehicleHash)vehicle.Model, vehicle.Position, vehicle.Heading, vehicle.NumberPlate,
                Convert.ToByte(vehicle.PrimaryColor), Convert.ToByte(vehicle.SecondaryColor), vehicle.Locked);
            player.SendNotification("Fahrzeug ~g~" + vehicle.DisplayName + "~s~ gespeichert.", true);
            player.SetIntoVehicle(vehicle, playerSeat);
          }
          else ChatService.SendMessage(player, "~m~Du sitzt in keinem Fahrzeug!");
          break;

        case "fvehicle":
          if (player.IsInVehicle)
          {
            string fIdStr = (option1 + " " + option2).Trim();
            int[] fIds = null;

            string[] fIdStrs = fIdStr.Split(" ");

            try
            {
              fIds = fIdStrs.Select(int.Parse).ToArray();
            }
            catch (Exception)
            {
              ChatService.ErrorMessage(player, "Es wurden fehlerhafte Fraktionen angegeben");
              return;
            }

            if (fIds.Any())
            {
              using (var dbContext = new DatabaseContext())
              {
                if (dbContext.Factions.Where(f => fIds.Contains(f.Id)).Count() != fIds.Length)
                {
                  ChatService.ErrorMessage(player, "Mindestens eine der angegeben Fraktionen existieren nicht");
                  return;
                }
              }
            }
            Vehicle vehicle = player.Vehicle;
            int playerSeat = player.VehicleSeat;
            vehicle = SaveManager.SaveFactionVehicleData(vehicle, (VehicleHash)vehicle.Model, vehicle.Position, vehicle.Heading, vehicle.NumberPlate,
                vehicle.PrimaryColor, vehicle.SecondaryColor, vehicle.Locked, vehicle.EngineStatus, fIds, vehicle.Livery);
            player.SendNotification("Fraktionsfahrzeug ~g~" + vehicle.DisplayName + "~s~ gespeichert.", true);
            player.SetIntoVehicle(vehicle, playerSeat);
          }
          else ChatService.SendMessage(player, "~m~Du sitzt in keinem Fahrzeug!");
          break;

        case "jvehicle":
          if (player.IsInVehicle)
          {
            if (option1 == null)
            {
              ChatService.ErrorMessage(player, "Du musst eine JobID als Parameter angeben");
              return;
            }
            else
            {
              if (!int.TryParse(option1, out int jobId))
              {
                ChatService.ErrorMessage(player, "Du musst eine gültige Zahl als JobID angeben");
                return;
              }

              Vehicle vehicle = player.Vehicle;
              vehicle = SaveManager.SaveJobVehicleData(vehicle, (VehicleHash)vehicle.Model, vehicle.Position, vehicle.Heading, vehicle.NumberPlate,
                  vehicle.PrimaryColor, vehicle.SecondaryColor, vehicle.Locked, vehicle.EngineStatus, jobId);
              player.SendNotification("Jobfahrzeug ~g~" + vehicle.DisplayName + "~s~ gespeichert.", true);
              player.SetIntoVehicle(vehicle, 0);
            }
          }
          else ChatService.SendMessage(player, "~m~Du sitzt in keinem Fahrzeug!");
          break;

        case "svehicle":
          if (player.IsInVehicle)
          {
            if (option1 == null || option2 == null)
            {
              ChatService.SendMessage(player, "~m~Benutzung: ~s~/save SVehicle [Carshop Business ID] [Preis]");
              return;
            }

            if (!int.TryParse(option1, out int businessId) || !int.TryParse(option2, out int price))
            {
              ChatService.SendMessage(player, "~m~Benutzung: ~s~/save SVehicle [Carshop Business ID] [Preis]");
              return;
            }

            BusinessBase business = BusinessManager.GetBusiness(businessId);
            if (business == null)
            {
              ChatService.ErrorMessage(player, "Dieses Business existiert nicht");
              return;
            }

            if (!(business is CarDealerBusinessBase))
            {
              ChatService.ErrorMessage(player, "Dieses Business ist kein Fahrzeug-Business");
              return;
            }

            Vehicle vehicle = player.Vehicle;
            int playerSeat = player.VehicleSeat;
            vehicle = SaveManager.SaveShopVehicleData(vehicle, (VehicleHash)vehicle.Model, vehicle.DisplayName, vehicle.Position, vehicle.Heading, vehicle.NumberPlate,
                Convert.ToByte(vehicle.PrimaryColor), Convert.ToByte(vehicle.SecondaryColor), business, price);
            player.SendNotification("Shopfahrzeug ~g~" + vehicle.DisplayName + "~s~ gespeichert.", true);
            Vector3 oldPos = player.Position;
            player.SafeTeleport(new Vector3(oldPos.X, oldPos.Y, oldPos.Z + 2.5));
          }
          else ChatService.SendMessage(player, "~m~Du sitzt in keinem Fahrzeug!");
          break;

        case "schoolvehicle":
          if (player.IsInVehicle)
          {
            if (option1 == null)
            {
              ChatService.SendMessage(player, "~m~Benutzung: ~s~/save schoolvehicle [FahrschuleID]");
              return;
            }
            if (!int.TryParse(option1, out int drivingSchoolId))
            {
              ChatService.SendMessage(player, "~m~Benutzung: ~s~/save schoolvehicle [FahrschuleID]");
              return;
            }
            if (drivingSchoolId > 2 || drivingSchoolId < 0)
            {
              ChatService.SendMessage(player, "~m~Diese Fahrschule existiert nicht.");
              return;
            }
            Vehicle vehicle = player.Vehicle;
            vehicle = SaveManager.SaveSchoolVehicleData(vehicle, (VehicleHash)vehicle.Model, vehicle.Position, vehicle.Heading, vehicle.NumberPlate,
                vehicle.PrimaryColor, vehicle.SecondaryColor, vehicle.Locked, vehicle.EngineStatus, drivingSchoolId);
            player.SendNotification("Fahrschulauto ~g~" + vehicle.DisplayName + "~s~ gespeichert.", true);
            player.SetIntoVehicle(vehicle, 0);
          }
          break;

        case "noobvehicle":
          if (player.IsInVehicle)
          {
            Vehicle vehicle = player.Vehicle;
            vehicle = SaveManager.SaveNoobVehicleData(vehicle, (VehicleHash)vehicle.Model, vehicle.Position, vehicle.Heading, vehicle.NumberPlate,
                vehicle.PrimaryColor, vehicle.SecondaryColor, vehicle.Locked, vehicle.EngineStatus);
            player.SendNotification("Noobfahrzeug ~g~" + vehicle.DisplayName + "~s~ gespeichert.", true);
            player.SetIntoVehicle(vehicle, 0);
          }
          break;

        case "location":
          if (option1 == null || option1.Length < 0)
          {
            ChatService.SendMessage(player, "~m~Benutzung: ~s~/save location [Beschreibung]");
            return;
          }

          using (var dbContext = new DatabaseContext())
          {
            dbContext.Locations.Add(new Location
            {
              Description = option1 + (option2 != null ? " " + option2 : ""),
              X = player.Position.X,
              Y = player.Position.Y,
              Z = player.Position.Z,
              Heading = player.Heading
            });

            dbContext.SaveChanges();

            player.SendNotification("Die Position wurde gespeichert");
          }
          break;
      }
    }

    [Command("remove", "~m~Benutzung: ~s~/remove [Vehicle, Goto] [Option]")]
    public void CmdAdminRemove(Player player, string type, string option = "")
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      switch (type.ToLower())
      {
        case "vehicle":
          if (!player.IsInVehicle)
          {
            ChatService.SendMessage(player, "~m~Du sitzt in keinem Fahrzeug!");
            return;
          }

          ServerVehicle veh = player.Vehicle.GetServerVehicle();
          if (veh == null)
          {
            ChatService.ErrorMessage(player, "Dieses Fahrzeug wird nicht von einem Server-System genutzt");
            return;
          }

          if (option.ToLower() != "yes")
          {
            ChatService.SendMessage(player, "Bist du sicher, dass du folgendes Fahrzeug löschen willst: ~m~" + veh.ToString() + " ~s~?");
            ChatService.SendMessage(player, "Falls ~g~Ja~s~, nutze ~y~/remove vehicle yes");
            return;
          }

          using (var dbContext = new DatabaseContext())
          {
            VehicleManager.DeleteVehicle(player.Vehicle);
            dbContext.ServerVehicles.Remove(veh);

            dbContext.SaveChanges();
          }
          break;

        case "goto":
          if (option == "")
          {
            ChatService.SendMessage(player, "~m~Benutzung: ~s~/remove [Goto] [Punkt]");
            return;
          }
          if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) //VON PROJEKTLEITER auf HEADADMIN
          {
            ChatService.NotAuthorized(player);
            return;
          }
          using (var dbContext = new DatabaseContext())
          {
            GotoPoint p = dbContext.GotoPoints.FirstOrDefault(x => x.Description == option);
            if (p == null)
            {
              ChatService.ErrorMessage(player, "Dieser Goto-Punkt existiert nicht");
              return;
            }

            dbContext.GotoPoints.Remove(p);
            dbContext.SaveChanges();

            player.SendNotification("Der Goto-Punkt ~r~" + p.Description + "~s~ wurde erfolgreich gelöscht.");
          }
          break;
      }
    }

    #region loadCommand

    [Command("load", "~m~Benutzung: ~s~/load [Typ = OnlineBunkers, ArcadiusBusinessCentre, MazeBankBuilding, LomBank, MazeBankWest, ClubWareHouse, SpecialLocations, GRHYacht, DHYacht, PYacht, AircraftCarrier, BridgeTC, BridgeTN, NorthYankton, ONeilsFarmB, ONeilsFarm, Morgue")]
    public void CmdAdminloadlocation(Player player, string typ)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      switch (typ)
      {
        case "OnlineBunkers":
          NAPI.World.RequestIpl("gr_case10_bunkerclosed");
          NAPI.World.RequestIpl("gr_case9_bunkerclosed");
          NAPI.World.RequestIpl("gr_case3_bunkerclosed");
          NAPI.World.RequestIpl("gr_case0_bunkerclosed");
          NAPI.World.RequestIpl("gr_case1_bunkerclosed");
          NAPI.World.RequestIpl("gr_case2_bunkerclosed");
          NAPI.World.RequestIpl("gr_case5_bunkerclosed");
          NAPI.World.RequestIpl("gr_case7_bunkerclosed");
          NAPI.World.RequestIpl("gr_case11_bunkerclosed");
          NAPI.World.RequestIpl("gr_case6_bunkerclosed");
          NAPI.World.RequestIpl("gr_case11_bunkerclosed");
          NAPI.World.RequestIpl("gr_case6_bunkerclosed");
          NAPI.World.RequestIpl("gr_case4_bunkerclosed");
          ChatService.SendMessage(player, "~y~ Online Bunkers~s~ erfolgreich geladen!");
          break;

        case "ArcadiusBusinessCentre":
          NAPI.World.RequestIpl("ex_dt1_02_office_02b");
          NAPI.World.RequestIpl("ex_dt1_02_office_02c");
          NAPI.World.RequestIpl("ex_dt1_02_office_02a");
          NAPI.World.RequestIpl("ex_dt1_02_office_01a");
          NAPI.World.RequestIpl("ex_dt1_02_office_01b");
          NAPI.World.RequestIpl("ex_dt1_02_office_01c");
          NAPI.World.RequestIpl("ex_dt1_02_office_03a");
          NAPI.World.RequestIpl("ex_dt1_02_office_03b");
          NAPI.World.RequestIpl("ex_dt1_02_office_03c");
          NAPI.World.RequestIpl("imp_dt1_02_cargarage_a");
          NAPI.World.RequestIpl("imp_dt1_02_cargarage_b");
          NAPI.World.RequestIpl("imp_dt1_02_cargarage_c");
          NAPI.World.RequestIpl("imp_dt1_02_modgarage");
          ChatService.SendMessage(player, "~y~ Arcadius Business Centre~s~ erfolgreich geladen!");
          break;

        case "MazeBankBuilding":
          NAPI.World.RequestIpl("ex_dt1_11_office_02b");
          NAPI.World.RequestIpl("ex_dt1_11_office_02c");
          NAPI.World.RequestIpl("ex_dt1_11_office_02a");
          NAPI.World.RequestIpl("ex_dt1_11_office_01a");
          NAPI.World.RequestIpl("ex_dt1_11_office_01b");
          NAPI.World.RequestIpl("ex_dt1_11_office_01c");
          NAPI.World.RequestIpl("ex_dt1_11_office_03a");
          NAPI.World.RequestIpl("ex_dt1_11_office_03b");
          NAPI.World.RequestIpl("ex_dt1_11_office_03c");
          NAPI.World.RequestIpl("imp_dt1_11_cargarage_a");
          NAPI.World.RequestIpl("imp_dt1_11_cargarage_b");
          NAPI.World.RequestIpl("imp_dt1_11_cargarage_c");
          NAPI.World.RequestIpl("imp_dt1_11_modgarage");
          ChatService.SendMessage(player, "~y~ Maze Bank Building~s~ erfolgreich geladen!");
          break;

        case "LomBank":
          NAPI.World.RequestIpl("ex_sm_13_office_02b");
          NAPI.World.RequestIpl("ex_sm_13_office_02c");
          NAPI.World.RequestIpl("ex_sm_13_office_02a");
          NAPI.World.RequestIpl("ex_sm_13_office_01a");
          NAPI.World.RequestIpl("ex_sm_13_office_01b");
          NAPI.World.RequestIpl("ex_sm_13_office_01c");
          NAPI.World.RequestIpl("ex_sm_13_office_03a");
          NAPI.World.RequestIpl("ex_sm_13_office_03b");
          NAPI.World.RequestIpl("ex_sm_13_office_03c");
          NAPI.World.RequestIpl("imp_sm_13_cargarage_a");
          NAPI.World.RequestIpl("imp_sm_13_cargarage_b");
          NAPI.World.RequestIpl("imp_sm_13_cargarage_c");
          NAPI.World.RequestIpl("imp_sm_13_modgarage");
          ChatService.SendMessage(player, "~y~Lom Bank~s~ erfolgreich geladen!");
          break;

        case "MazeBankWest":
          NAPI.World.RequestIpl("ex_sm_15_office_02b");
          NAPI.World.RequestIpl("ex_sm_15_office_02c");
          NAPI.World.RequestIpl("ex_sm_15_office_02a");
          NAPI.World.RequestIpl("ex_sm_15_office_01a");
          NAPI.World.RequestIpl("ex_sm_15_office_01b");
          NAPI.World.RequestIpl("ex_sm_15_office_01c");
          NAPI.World.RequestIpl("ex_sm_15_office_03a");
          NAPI.World.RequestIpl("ex_sm_15_office_03b");
          NAPI.World.RequestIpl("ex_sm_15_office_03c");
          NAPI.World.RequestIpl("imp_sm_15_cargarage_a");
          NAPI.World.RequestIpl("imp_sm_15_cargarage_b");
          NAPI.World.RequestIpl("imp_sm_15_cargarage_c");
          NAPI.World.RequestIpl("imp_sm_15_modgarage");
          ChatService.SendMessage(player, "~y~Maze Bank West~s~ erfolgreich geladen!");
          break;

        case "ClubWareHouse":
          NAPI.World.RequestIpl("bkr_biker_interior_placement_interior_0_biker_dlc_int_01_milo");
          NAPI.World.RequestIpl("bkr_biker_interior_placement_interior_1_biker_dlc_int_02_milo");
          NAPI.World.RequestIpl("bkr_biker_interior_placement_interior_2_biker_dlc_int_ware01_milo");
          NAPI.World.RequestIpl("bkr_biker_interior_placement_interior_3_biker_dlc_int_ware02_milo");
          NAPI.World.RequestIpl("bkr_biker_interior_placement_interior_4_biker_dlc_int_ware03_milo");
          NAPI.World.RequestIpl("bkr_biker_interior_placement_interior_5_biker_dlc_int_ware04_milo");
          NAPI.World.RequestIpl("bkr_biker_interior_placement_interior_6_biker_dlc_int_ware05_milo");
          NAPI.World.RequestIpl("ex_exec_warehouse_placement_interior_1_int_warehouse_s_dlc_milo");
          NAPI.World.RequestIpl("ex_exec_warehouse_placement_interior_0_int_warehouse_m_dlc_milo");
          NAPI.World.RequestIpl("ex_exec_warehouse_placement_interior_2_int_warehouse_l_dlc_milo");
          NAPI.World.RequestIpl("imp_impexp_interior_placement_interior_1_impexp_intwaremed_milo_");
          NAPI.World.RequestIpl("bkr_bi_hw1_13_int");
          ChatService.SendMessage(player, "~y~Clubs & Warehouses~s~ erfolgreich geladen!");
          break;

        case "SpecialLocations":
          NAPI.World.RequestIpl("cargoship");
          NAPI.World.RequestIpl("sunkcargoship");
          NAPI.World.RequestIpl("SUNK_SHIP_FIRE");
          NAPI.World.RequestIpl("redCarpet");
          NAPI.World.RequestIpl("DES_StiltHouse_imapend");
          NAPI.World.RequestIpl("DES_stilthouse_rebuild");
          NAPI.World.RequestIpl("FINBANK");
          NAPI.World.RequestIpl("TrevorsMP");
          NAPI.World.RequestIpl("TrevorsTrailerTidy");
          NAPI.World.RequestIpl("SP1_10_real_interior");
          NAPI.World.RequestIpl("refit_unload");
          NAPI.World.RequestIpl("post_hiest_unload");
          NAPI.World.RequestIpl("FIBlobby");
          ChatService.SendMessage(player, "~y~Special Locations~s~ erfolgreich geladen!");
          break;

        case "GRHYacht":
          NAPI.World.RequestIpl("gr_heist_yacht2");
          NAPI.World.RequestIpl("gr_heist_yacht2_bar");
          NAPI.World.RequestIpl("gr_heist_yacht2_bedrm");
          NAPI.World.RequestIpl("gr_heist_yacht2_bridge");
          NAPI.World.RequestIpl("gr_heist_yacht2_enginrm");
          NAPI.World.RequestIpl("gr_heist_yacht2_lounge");
          ChatService.SendMessage(player, "~y~Gunrunning heist Yacht~s~ erfolgreich geladen!");
          break;

        case "DHYacht":
          NAPI.World.RequestIpl("hei_yacht_heist");
          NAPI.World.RequestIpl("hei_yacht_heist_enginrm");
          NAPI.World.RequestIpl("hei_yacht_heist_Lounge");
          NAPI.World.RequestIpl("hei_yacht_heist_Bridge");
          NAPI.World.RequestIpl("hei_yacht_heist_Bar");
          NAPI.World.RequestIpl("hei_yacht_heist_Bedrm");
          NAPI.World.RequestIpl("hei_yacht_heist_DistantLights");
          NAPI.World.RequestIpl("hei_yacht_heist_LODLights");
          ChatService.SendMessage(player, "~y~Dignity heist Yacht~s~ erfolgreich geladen!");
          break;

        case "PYacht":
          NAPI.World.RequestIpl("smboat");
          NAPI.World.RequestIpl("smboat_lod");
          ChatService.SendMessage(player, "~y~Party Yacht~s~ erfolgreich geladen!");
          break;

        case "AircraftCarrier":
          NAPI.World.RequestIpl("hei_carrier");
          NAPI.World.RequestIpl("hei_carrier_DistantLights");
          NAPI.World.RequestIpl("hei_Carrier_int1");
          NAPI.World.RequestIpl("hei_Carrier_int2");
          NAPI.World.RequestIpl("hei_Carrier_int3");
          NAPI.World.RequestIpl("hei_Carrier_int4");
          NAPI.World.RequestIpl("hei_Carrier_int5");
          NAPI.World.RequestIpl("hei_Carrier_int6");
          NAPI.World.RequestIpl("hei_carrier_LODLights");
          ChatService.SendMessage(player, "~y~Aircraft Carrier~s~ erfolgreich geladen!");
          break;

        case "BridgeTC":
          NAPI.World.RequestIpl("canyonriver01_traincrash");
          NAPI.World.RequestIpl("canyonriver01_traincrash");
          ChatService.SendMessage(player, "~y~Bridge Train Crash~s~ erfolgreich geladen!");
          break;

        case "BridgeTN":
          NAPI.World.RequestIpl("canyonriver01");
          NAPI.World.RequestIpl("railing_start");
          ChatService.SendMessage(player, "~y~Bridge Train Normal~s~ erfolgreich geladen!");
          break;

        case "NorthYankton":
          NAPI.World.RequestIpl("prologue01");
          NAPI.World.RequestIpl("prologue01c");
          NAPI.World.RequestIpl("prologue01d");
          NAPI.World.RequestIpl("prologue01e");
          NAPI.World.RequestIpl("prologue01f");
          NAPI.World.RequestIpl("prologue01g");
          NAPI.World.RequestIpl("prologue01h");
          NAPI.World.RequestIpl("prologue01i");
          NAPI.World.RequestIpl("prologue01j");
          NAPI.World.RequestIpl("prologue01k");
          NAPI.World.RequestIpl("prologue01z");
          NAPI.World.RequestIpl("prologue02");
          NAPI.World.RequestIpl("prologue03");
          NAPI.World.RequestIpl("prologue03b");
          NAPI.World.RequestIpl("prologue03_grv_dug");
          NAPI.World.RequestIpl("prologue_grv_torch");
          NAPI.World.RequestIpl("prologue04");
          NAPI.World.RequestIpl("prologue04b");
          NAPI.World.RequestIpl("prologue04_cover");
          NAPI.World.RequestIpl("des_protree_end");
          NAPI.World.RequestIpl("des_protree_start");
          NAPI.World.RequestIpl("prologue05");
          NAPI.World.RequestIpl("prologue05b");
          NAPI.World.RequestIpl("prologue06");
          NAPI.World.RequestIpl("prologue06b");
          NAPI.World.RequestIpl("prologue06_int");
          NAPI.World.RequestIpl("prologue06_pannel");
          NAPI.World.RequestIpl("plg_occl_00");
          NAPI.World.RequestIpl("prologue_occl");
          NAPI.World.RequestIpl("prologuerd");
          NAPI.World.RequestIpl("prologuerdb");
          ChatService.SendMessage(player, "~y~North Yankton~s~ erfolgreich geladen!");
          break;

        case "ONeilsFarmB":
          NAPI.World.RequestIpl("farmint");
          NAPI.World.RequestIpl("farm_burnt");
          NAPI.World.RequestIpl("farm_burnt_props");
          NAPI.World.RequestIpl("des_farmhs_endimap");
          NAPI.World.RequestIpl("des_farmhs_end_occl");
          ChatService.SendMessage(player, "~y~ONeils Farm Burnt~s~ erfolgreich geladen!");
          break;

        case "ONeilsFarm":
          NAPI.World.RequestIpl("farm");
          NAPI.World.RequestIpl("farm_props");
          NAPI.World.RequestIpl("farm_int");
          ChatService.SendMessage(player, "~y~ONeils Farm~s~ erfolgreich geladen!");
          break;

        case "Morgue":
          NAPI.World.RequestIpl("coronertrash");
          NAPI.World.RequestIpl("Coroner_Int_On");
          ChatService.SendMessage(player, "~y~Morgue~s~ erfolgreich geladen!");
          break;
      }
    }

    #endregion loadCommand

    //
    [Command("managefactionranks", "~m~Benutzung: ~s~/managefactionranks [Fraktions-ID]", Alias = "mfr")]
    public void CmdFactionManageFactionRanks(Player player, int factionID)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      using (var context = new DatabaseContext())
      {
        Faction f = context.Factions.FirstOrDefault(id => id.Id == factionID);
        if (f == null)
        {
          ChatService.ErrorMessage(player, "Diese Fraktion existiert nicht (Liste: ~m~/factionlist~s~)");
          return;
        }

        List<FactionRank> factionRanks = context.FactionRanks.Where(r => r.FactionId == f.Id).OrderByDescending(o => o.Order).ToList();
        List<Rank> rankList = new List<Rank>();

        factionRanks.ForEach(r =>
        {
          rankList.Add(new Rank
          {
            Id = r.Id,
            Name = r.RankName
          });
        });

        FactionRankHelper helper = new FactionRankHelper
        {
          FactionName = f.Name,
          FactionId = f.Id,
          Ranks = rankList
        };

        string json = JsonConvert.SerializeObject(helper, Formatting.None);
        player.TriggerEvent("manageFactionRanks", json);
      }
    }

    [Command("setdoor", "~m~Benutzung: ~s~/setdoor [open/shut] [Tür] [Boolean:Permanet] [Boolean:Lose]")]
    public void CmdAdminSetDoorOpen(Player player, string status, int door, bool permanent = false, bool lose = true)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      switch (status.ToLower())
      {
        case "open":
          {
            player.TriggerEvent("CLIENT:SetDoorOpen", door, lose, permanent);
            player.SendChatMessage($"CLIENT:SetDoorOpen, {door}, {lose}, {permanent}");
            break;
          }
        case "shut":
          {
            player.TriggerEvent("CLIENT:SetDoorShut", door, permanent);
            player.SendChatMessage($"CLIENT:SetDoorShut, {door}, {permanent}");
            break;
          }
      }
    }

    [Command("aplaysound", "~m~Benutzung: ~s~/aplaysound [Dateiname] [mp3/wav] [volume 0.0 - 100.0]", Alias = "aps")]
    public void CmdAdminPlaySound(Player player, string sound, string typ, double volume = 100)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      player.TriggerEvent("CLIENT:PlaySound", sound, typ, volume);
    }

    [Command("astopsound", "~m~Benutzung: ~s~/astopsound", Alias = "ass")]
    public void CmdAdminStopSound(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      player.TriggerEvent("CLIENT:StopSound");
    }

    [Command("aspeed", "~m~Benutzung: ~s~/aspeed [Modifier1] [Modifier2]")] //TODO: Überarbeiten ?? SetPlayerVelocity ??
    public void CmdAdminAspeed(Player player, int modifier, int modifier2 = 1)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (!player.IsInVehicle)
      {
        ChatService.ErrorMessage(player, "Du sitzt momentan nicht in einem Fahrzeug");
        return;
      }

      /*if (modifier < 0)
      {
        ChatService.ErrorMessage(player, "Es muss positives Adminspeed angegeben werden");
        return;
      }*/

      player.Vehicle.SetSharedData("vehicleAdminSpeed", modifier);
      player.Vehicle.SetSharedData("vehicleAdminSpeed2", modifier2);
    }

    [Command("setmoney", "~m~Benutzung: ~s~/setmoney [Name] [Menge]")]
    public void SetPlayerMoney(Player player, string receiver, int amount)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      Player target = PlayerService.GetPlayerByNameOrId(receiver);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      using (var dbContext = new DatabaseContext())
      {
        target.GetUser(dbContext).BankAccount.Balance = amount;
        dbContext.SaveChanges();
      }
      ChatService.SendMessage(player, "~b~[ADMIN]~s~ Du hast das Geld von " + target.Name + " auf ~g~$" + amount + "~s~ gesetzt.");
      ChatService.SendMessage(target, "~b~[ADMIN]~s~ Dein Geld wurde von Admin " + player.Name + " auf ~g~$" + amount + "~s~ gesetzt.");
    }

    [Command("givemoney", "~m~Benutzung: ~s~/givemoney [Name] [Menge]")]
    public void GivePlayerMoney(Player player, string receiver, int amount)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(receiver);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      using (var dbContext = new DatabaseContext())
      {
        target.GetUser(dbContext).BankAccount.Balance += amount;
        dbContext.SaveChanges();
      }
      ChatService.SendMessage(player, "~b~[ADMIN]~s~ Du hast " + target.Name + " ~g~$" + amount + "~s~ gegeben.");
      ChatService.SendMessage(target, "~b~[ADMIN]~s~ Admin " + player.Name + " hat dir ~g~$" + amount + "~s~ gegeben.");
    }

    [Command("setbusinessowner", "~m~Benutzung: ~s~/setbusinessowner [Name] [Business ID]")]
    public void CmdAdminSetbusinessowner(Player player, string name, int businessid)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(name);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      if (target.GetUser().BusinessId != null)
      {
        ChatService.ErrorMessage(player, "Der Spieler besitzt momentan schon ein Business: ~o~" + BusinessManager.GetBusiness(target.GetUser().BusinessId).Name);
        return;
      }

      BusinessBase business = BusinessManager.GetBusiness(businessid);
      if (business == null)
      {
        ChatService.ErrorMessage(player, "Dieses Business existiert nicht. ~m~/businesslist");
        return;
      }

      if (business.GetOwner() != null)
      {
        ChatService.ErrorMessage(player, "Das Business hat momentan noch einen Besitzer: ~o~" + business.GetOwner().Name + "~s~. Entferne diesen Besitzer erst mit ~m~/clearbusiness");
        return;
      }

      using (var dbContext = new DatabaseContext())
      {
        User targetUser = target.GetUser(dbContext);
        targetUser.BusinessId = businessid;

        dbContext.SaveChanges();
        business.Update();
      }
    }

    [Command("clearbusiness", "~m~Benutzung:~s~ /clearbusiness [Business ID]")]
    public void CmdAdminClearbusiness(Player player, int businessid)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      BusinessBase business = BusinessManager.GetBusiness(businessid);
      if (business == null)
      {
        ChatService.ErrorMessage(player, "Dieses Business existiert nicht. ~m~/businesslist");
        return;
      }

      using (var dbContext = new DatabaseContext())
      {
        User owner = business.GetOwner(dbContext);
        if (owner == null)
        {
          ChatService.ErrorMessage(player, "Dieses Business hat momentan keinen Besitzer");
          return;
        }

        owner.BusinessId = null;
        business.GetBankAccount(dbContext).Balance = 0;

        ChatService.SendMessage(owner.Player, "~b~[ADMIN]~s~ Dir wurde von ~y~" + player.Name + "~s~ dein Business entzogen.");
        ChatService.SendMessage(player, "~b~[ADMIN]~s~ Du hast ~y~" + owner.Name + "~s~ sein Business ~o~" + business.Name + "~s~ entzogen.");

        dbContext.SaveChanges();
        business.Update();
      }
    }

    [Command("setbusinessbankbalance", "~m~Benutzung: ~s~/setbusinessbankbalance [Business ID] [Menge]")]
    public void CmdAdminGivebusinessbankbalance(Player player, int businessid, int amount)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      BusinessBase business = BusinessManager.GetBusiness(businessid);
      if (business == null)
      {
        ChatService.ErrorMessage(player, "Dieses Business existiert nicht. ~m~/businesslist");
        return;
      }

      BankManager.SetMoney(player, business, amount, "Admin");
    }

    //[Command("interior", "~m~Benutzung: ~s~/interior [Add / Remove / SetEnter / SetExit] [Name / ID]")]
    //public void CmdAdminInterior(Player player, string option1, string option2)
    //{
    //  if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
    //  {
    //    ChatService.NotAuthorized(player);
    //    return;
    //  }

    //}

    [Command("reloaddoors", "~m~Benutzung: ~s~/reloaddoors")]
    public void CmdAdminReloaddoors(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      DoorManager.ReloadDoors();
      ChatService.SendMessage(player, "~b~[ADMIN]~s~ Die Türen wurden erfolgreich neugeladen.");
    }

    //[Command("house", "~m~Benutzung: ~s~/house [add / remove / price / type / reloadhouses]", GreedyArg = true)]
    //public void CmdAdminHouse(Player player, string option1 = null, string option2 = null)
    //{
    //}

    [Command("paydaydrop", "~m~Benutzung: ~s~/paydaydrop")]
    public void CmdAdminPaydaydrop(Player player)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      foreach (var target in NAPI.Pools.GetAllPlayers())
      {
        if (target.IsLoggedIn())
        {
          Economy.SetPaycheck(target, false);
        }
      }

      ChatService.SendMessage(player, "~b~[ADMIN]~s~ Du hast ein Payday gedroppt.");
    }

    [Command("setwage", "~m~Benutzung: ~s~/setwage [Name/Id] [Lohn]")]
    public void CmdAdminSetWage(Player player, string nameOrId, int wage)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(nameOrId);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      using (var dbContext = new DatabaseContext())
      {
        target.GetUser(dbContext).Wage += wage;
        dbContext.SaveChanges();
      }
    }

    [Command("setweaponrack", "~m~Benutzung: ~s~/setweaponrack [Fraktion ID] [Waffen Model] [SlotID (1-4)]")]
    public void CmdAdminSetWeaponrack(Player player, int factionID, string weaponModel, int slotId)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      using (var dbContext = new DatabaseContext())
      {
        Faction f = dbContext.Factions.FirstOrDefault(x => x.Id == factionID);
        if (f == null)
        {
          ChatService.ErrorMessage(player, "Diese Fraktion existiert nicht (Liste: ~m~/factionlist~s~)");
          return;
        }
        if (weaponModel != "Schutzweste")
        {
          if (!uint.TryParse(weaponModel, out uint weapon))
          {
            if (weaponModel.Contains("mk2") && !weaponModel.Contains("_mk2")) weaponModel = weaponModel.Replace("mk2", "_mk2");
            weapon = NAPI.Util.GetHashKey($"weapon_{weaponModel}");
          }

          if (!WeaponManager.IsValidHash(weapon))
          {
            ChatService.ErrorMessage(player, "Diese Waffe existiert nicht");
            return;
          }

          FactionWeapon fw = dbContext.FactionWeapons.FirstOrDefault(w => w.FactionId == factionID && w.WeaponModel == weaponModel);
          if (fw == null)
          {
            var newWeapon = new FactionWeapon
            {
              WeaponModel = weaponModel,
              SlotID = slotId,
              Rank = 12,
              FactionId = factionID
            };
            dbContext.FactionWeapons.Add(newWeapon);
            dbContext.SaveChanges();
            ChatService.SendMessage(player, "Neuer Waffeneintrag für die Fraktion " + f.Name + ": " + weaponModel + ", SlotId: " + slotId);
            return;
          }

          fw.SlotID = slotId;
          dbContext.SaveChanges();
          ChatService.SendMessage(player, "Waffeneintrag bearbeitet für die Fraktion " + f.Name + ": " + weaponModel + ", SlotId: " + slotId);
          return;
        }

        FactionWeapon fw2 = dbContext.FactionWeapons.FirstOrDefault(w => w.FactionId == factionID && w.WeaponModel == weaponModel);
        if (fw2 == null)
        {
          var schutzweste = new FactionWeapon
          {
            WeaponModel = weaponModel,
            SlotID = slotId,
            Rank = 12,
            FactionId = factionID
          };
          dbContext.FactionWeapons.Add(schutzweste);
          dbContext.SaveChanges();
          ChatService.SendMessage(player, "Neuer Waffeneintrag für die Fraktion " + f.Name + ": " + weaponModel + ", SlotId: " + slotId);
          return;
        }

        fw2.SlotID = slotId;
        dbContext.SaveChanges();
        ChatService.SendMessage(player, "Waffeneintrag bearbeitet für die Fraktion " + f.Name + ": " + weaponModel + ", SlotId: " + slotId);
        return;
      }
    }

    [Command("rmweaponrack", "~m~Benutzung: ~s~/rmweaponrack [Fraktion ID] [Waffen Model]")]
    public void CmdAdminRmWeaponrack(Player player, int factionID, string weaponModel)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      using (var dbContext = new DatabaseContext())
      {
        Faction f = dbContext.Factions.FirstOrDefault(x => x.Id == factionID);
        if (f == null)
        {
          ChatService.ErrorMessage(player, "Diese Fraktion existiert nicht (Liste: ~m~/factionlist~s~)");
          return;
        }
        if (weaponModel != "Schutzweste")
        {
          if (!uint.TryParse(weaponModel, out uint weapon))
          {
            if (weaponModel.Contains("mk2") && !weaponModel.Contains("_mk2")) weaponModel = weaponModel.Replace("mk2", "_mk2");
            weapon = NAPI.Util.GetHashKey($"weapon_{weaponModel}");
          }

          if (!WeaponManager.IsValidHash(weapon))
          {
            ChatService.ErrorMessage(player, "Diese Waffe existiert nicht");
            return;
          }

          FactionWeapon fw = dbContext.FactionWeapons.FirstOrDefault(w => w.FactionId == factionID && w.WeaponModel == weaponModel);
          if (fw != null)
          {
            dbContext.FactionWeapons.Remove(fw);
            ChatService.SendMessage(player, "Waffe entsorgt für die Fraktion " + f.Name + ": " + weaponModel);
            dbContext.SaveChanges();
            return;
          }
          ChatService.ErrorMessage(player, "Diese Waffe befindet sich nicht im Waffenlager");
          return;
        }
        FactionWeapon fw2 = dbContext.FactionWeapons.FirstOrDefault(w => w.FactionId == factionID && w.WeaponModel == weaponModel);
        if (fw2 != null)
        {
          dbContext.FactionWeapons.Remove(fw2);
          ChatService.SendMessage(player, "Schutzweste entsorgt für die Fraktion " + f.Name + ": " + weaponModel);
          dbContext.SaveChanges();
          return;
        }
        ChatService.ErrorMessage(player, "Es befindet sich keine Schutzweste im Waffenlager");
      }
    }

    [Command("business", "~m~Benutzung:~s~ /business [price] [Option]")]
    public void CmdAdminBusiness(Player player, string option, string option1)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      BusinessBase business = BusinessManager.GetNearBusiness(player);

      if (business == null)
      {
        ChatService.ErrorMessage(player, "In deiner Nähe ist kein Business");
        return;
      }

      switch (option.ToLower())
      {
        case "price":
          if (!int.TryParse(option1, out int price))
          {
            ChatService.ErrorMessage(player, "Es muss ein gültiger Preis angegeben werden");
            return;
          }
          using (var dbContext = new DatabaseContext())
          {
            BusinessData data = business.GetData(dbContext);
            data.Price = price;
            dbContext.SaveChanges();

            player.SendChatMessage($"Der Preis wurde auf {price.ToMoneyString()} gesetzt");

            business.Update();
            return;
          }
      }

      player.SendChatMessage("~m~Benutzung:~s~ /business [price] [Option]");
    }

    [Command("checkstats", "~m~Benutzung:~s~ /checkstats [Spieler]")]
    public void CmdAdminCheckStats(Player player, string nameOrId)
    {
      User user = player.GetUser();
      if (!user.IsAdmin(AdminLevel.SUPPORTER))
      {
        ChatService.NotAuthorized(player);
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(nameOrId);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      User targetUser = target.GetUser();
      int handmoney = targetUser.Handmoney;
      int bankmoney = targetUser.BankAccount.Balance;
      bool driverLicense = targetUser.DriverLicenseVehicle;
      bool bikeLicense = targetUser.DriverLicenseBike;
      bool flyingLicense = targetUser.FlyingLicensePlane;
      bool weaponLicense = targetUser.WeaponLicense;
      int playedHours = targetUser.PlayedMinutes / 60;
      string playedHoursString = "";
      int jailTime = targetUser.JailTime;

      if (user.IsAdmin(AdminLevel.HEADADMIN)) {
        playedHoursString = playedHours.ToString();
      } else {
        int newbiePlayedHoursThreshold = GlobalHelper.newbiePlayedMinutesThreshold / 60;
        playedHoursString = playedHours > newbiePlayedHoursThreshold ? (newbiePlayedHoursThreshold + "+") : playedHours.ToString();
      }

      ChatService.SendMessage(player, $"Statistiken von {target.Name} - HandMoney: {handmoney.ToMoneyString()}, BankMoney: {bankmoney.ToMoneyString()}, DriverLicense: {driverLicense.ToString()}, BikeLicense: {bikeLicense.ToString()}, FlyingLicense: {flyingLicense.ToString()}, WeaponLicense: {weaponLicense.ToString()}, playedHours: {playedHoursString}, JailTime: {jailTime.ToString()}");
    }

    #endregion ALevel1337

    #region ALevel1338

    [Command("whitelist", "~m~Benutzung: ~s~/whitelist [Add / Remove] [Socialclub Name]")]
    public void CmdAdminWhitelist(Player player, string option, string scName)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.PROJEKTLEITUNG) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      option = option.ToLower();

      if (option != "add" && option != "remove")
      {
        ChatService.SendMessage(player, "~m~Benutzung: ~s~/whitelist [Add / Remove] [Socialclub Name]");
        return;
      }

      using (var dbContext = new DatabaseContext())
      {
        if (option == "add")
        {
          if (dbContext.WhitelistEntries.Any(w => w.SocialClubName.ToLower() == scName.ToLower()))
          {
            ChatService.ErrorMessage(player, "Dieser Name ist schon auf der Whitelist");
            return;
          }

          Whitelist whitelist = new Whitelist { SocialClubName = scName.ToLower() };
          dbContext.WhitelistEntries.Add(whitelist);

          ChatService.SendMessage(player, "~b~[ADMIN]~s~ ~y~" + scName + "~s~ wurde erfolgreich zur Whitelist hinzugefügt.");
        }
        else if (option == "remove")
        {
          if (!dbContext.WhitelistEntries.Any(w => w.SocialClubName.ToLower() == scName.ToLower()))
          {
            ChatService.ErrorMessage(player, "Dieser Name ist nicht auf der Whitelist");
            return;
          }

          Whitelist whitelist = dbContext.WhitelistEntries.FirstOrDefault(w => w.SocialClubName.ToLower() == scName.ToLower());
          dbContext.WhitelistEntries.Remove(whitelist);

          ChatService.SendMessage(player, "~b~[ADMIN]~s~ ~y~" + scName + "~s~ wurde erfolgreich aus der Whitelist entfernt.");
        }
        dbContext.SaveChanges();
      }
    }

    [Command("blind", "~m~Benutzung: ~s~/blind [Spieler] [Mode]")]
    public void CmdBlind(Player player, string name, int mode)
    {
      if (!player.IsLoggedIn()) return;

      if (!player.GetUser()?.IsAdmin(AdminLevel.PROJEKTLEITUNG) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }
      Player target = PlayerService.GetPlayerByNameOrId(name);

      if (mode == 1)
      {
        target.TriggerEvent("toggleBlackScreen", true);
        ChatService.BroadcastAdmin("~b~[ADMIN]~s~ " + player.Name + " hat " + target.Name + " einen Blackscreen gesetzt. ", AdminLevel.ADMIN);
      }
      else if (mode == 0)
      {
        target.TriggerEvent("toggleBlackScreen", false);
        ChatService.BroadcastAdmin("~b~[ADMIN]~s~ " + player.Name + " hat " + target.Name + " den Blackscreen entfernt. ", AdminLevel.ADMIN);
      }
    }

    [Command("makeadmin", "~m~Benutzung: ~s~/makeadmin [Name] [Adminlevel]")]
    public void CmdAdminMakeadmin(Player player, string name, int rank)
    {
      if (!player.GetUser()?.IsAdmin(AdminLevel.PROJEKTLEITUNG) ?? true)
      {
        ChatService.NotAuthorized(player);
        return;
      }

      if (!Enum.IsDefined(typeof(AdminLevel), rank))
      {
        ChatService.ErrorMessage(player, "Dieser Adminrang ist nicht definiert");
        return;
      }

      Player target = PlayerService.GetPlayerByNameOrId(name);
      if (target == null || !target.IsLoggedIn())
      {
        ChatService.PlayerNotFound(player);
        return;
      }

      using (var dbContext = new DatabaseContext())
      {
        target.GetUser(dbContext).AdminLevel = (AdminLevel)rank;
        dbContext.SaveChanges();
      }

      ChatService.SendMessage(target, "~b~[ADMIN]~s~ Du wurdest durch ~y~" + player.Name + " ~s~auf Adminlevel ~y~" + target.GetUser().AdminLevel.GetName() + " ~y~(" + rank + ") ~s~gesetzt.");
      ChatService.SendMessage(player, "~b~[ADMIN]~s~ Du hast ~y~" + target.Name + " ~s~auf Adminlevel ~y~" + target.GetUser().AdminLevel.GetName() + " ~y~(" + rank + ") ~s~gesetzt.");
    }

    #endregion ALevel1338

    [RemoteEvent("Noclip")]
    public void Noclip(Player player)
    {
      if (!player.GetUser().IsAdmin(AdminLevel.HEADADMIN))
      {
        return;
      }
      if (!player.IsTSupport())
      {
        ChatService.ErrorMessage(player, "Du bist nicht im T-Support");
        return;
      }

      if (player.HasData("Adminduty") && player.GetData<bool>("Adminduty"))
        player.TriggerEvent("ADMIN:NoClip");
    }
  }
}
