diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index 27c6a4cf..594e029b 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -2021,7 +2021,8 @@ namespace ReallifeGamemode.Server.Commands [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) + User user = player.GetUser(); + if (!user.IsAdmin(AdminLevel.ADMIN)) { ChatService.NotAuthorized(player); return; @@ -2041,6 +2042,12 @@ namespace ReallifeGamemode.Server.Commands return; } + if (!WeaponManager.IsAllowedWeapon(weapon) && !user.IsAdmin(AdminLevel.HEADADMIN)) + { + ChatService.ErrorMessage(player, "Du darfst diese Waffe nicht vergeben"); + return; + } + WeaponHash weaponHash = (WeaponHash)uHash; var peopleInRange = NAPI.Player.GetPlayersInRadiusOfPlayer(radius, player); @@ -2057,7 +2064,7 @@ namespace ReallifeGamemode.Server.Commands [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) + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) { ChatService.NotAuthorized(player); return; @@ -2076,7 +2083,7 @@ namespace ReallifeGamemode.Server.Commands [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) + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) { ChatService.NotAuthorized(player); return; @@ -3896,7 +3903,8 @@ namespace ReallifeGamemode.Server.Commands [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) + User user = player.GetUser(); + if (!user.IsAdmin(AdminLevel.ADMIN)) { ChatService.NotAuthorized(player); return; @@ -3929,6 +3937,12 @@ namespace ReallifeGamemode.Server.Commands return; } + if (!WeaponManager.IsAllowedWeapon(hash) && !user.IsAdmin(AdminLevel.HEADADMIN)) + { + ChatService.ErrorMessage(player, "Du darfst diese Waffe nicht vergeben"); + 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."); diff --git a/ReallifeGamemode.Server/Managers/WeaponManager.cs b/ReallifeGamemode.Server/Managers/WeaponManager.cs index dc111434..75a7390f 100644 --- a/ReallifeGamemode.Server/Managers/WeaponManager.cs +++ b/ReallifeGamemode.Server/Managers/WeaponManager.cs @@ -105,6 +105,26 @@ namespace ReallifeGamemode.Server.Managers "militaryrifle" }; + private static readonly List _restrictedWeapons = new List() + { + "bat", + "flashlight", + "knuckle", + "nightstick", + "pistol", + "pistol_mk2", + "combatpistol", + "stungun", + "pistol50", + "smg", + "assaultsmg", + "combatpdw", + "pumpshotgun", + "assaultrifle", + "carbinerifle", + "sniperrifle" + }; + private static readonly Dictionary causeOfDeath = new Dictionary() { { 2460120199, "Antique Cavalry Dagger"}, @@ -341,6 +361,8 @@ namespace ReallifeGamemode.Server.Managers { 1470379660 ,"Perico Pistol" }, }; + public static bool IsAllowedWeapon(string name) => _restrictedWeapons.Contains(name.ToLower()); + public static bool IsValidHash(uint hash) { foreach (WeaponHash vh in Enum.GetValues(typeof(WeaponHash)))