From 19847fb8d9fcf06b3b0d9234709129083dca5aca Mon Sep 17 00:00:00 2001 From: hydrant Date: Sun, 9 May 2021 20:49:58 +0200 Subject: [PATCH] giveweapon, clothes, props headadmin --- .../Commands/AdminCommands.cs | 218 +++++++++--------- 1 file changed, 109 insertions(+), 109 deletions(-) diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index 2708ce9f..0f30a33b 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -1405,74 +1405,6 @@ namespace ReallifeGamemode.Server.Commands 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("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) { @@ -1722,47 +1654,6 @@ namespace ReallifeGamemode.Server.Commands 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) { @@ -3919,6 +3810,115 @@ namespace ReallifeGamemode.Server.Commands ChatService.SendMessage(player, $"~b~[ADMIN]~s~ Der Kaufpreis des Fahrzeugs ~y~{serverVehicle.Id}~s~ wurde auf ~g~{price.ToMoneyString()} gesetzt. Alter Preis: {oldPriceStr}"); } + [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.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()) + { + User user = target.GetUser(dbContext); + bool duty = user.GetData("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.HEADADMIN) ?? 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("giveweapon", "~m~Benutzung: ~s~/giveweapon [Spieler] [Waffe] [Munition]")] + public void CmdAdminGiveweapon(Player player, string name, string hash, int ammo) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? 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."); + } + #endregion ALevel1337 #region ALevel1338