diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..f2fe8c8 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "discord.removeDetails": false, + "discord.removeLowerDetails": false, + "discord.removeRemoteRepository": true +} \ No newline at end of file diff --git a/CS2-SimpleAdmin.cs b/CS2-SimpleAdmin.cs index a263433..c178296 100644 --- a/CS2-SimpleAdmin.cs +++ b/CS2-SimpleAdmin.cs @@ -916,18 +916,28 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig ", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)] public void OnGiveCommand(CCSPlayerController? caller, CommandInfo command) { - if(!GetTarget(command, out var player) || player == null || !player.IsValid) return; + string weaponName = command.GetArg(2); - string weapon = command.GetArg(2); - player.GiveNamedItem(weapon); - - Server.PrintToChatAll(Helper.ReplaceTags($" {Config.Prefix} {Config.Messages.AdminGiveMessage}".Replace("{ADMIN}", caller?.PlayerName == null ? "Console" : caller.PlayerName).Replace("{WEAPON}", weapon.Split("_")[1])).Replace("{PLAYER}",player.PlayerName)); + //check if weapon is inside the bannedItems + foreach(string bannedWeapon in BannedGiveItems){ + if(bannedWeapon.Equals(weaponName.ToLower())){ + command.ReplyToCommand($"Cannot Give {weaponName} because it's illegal to be given."); + return; + } + } + //give the weapon to player and announce it + player.GiveNamedItem(weaponName); + Server.PrintToChatAll(Helper.ReplaceTags($" {Config.Prefix} {Config.Messages.AdminGiveMessage}".Replace("{ADMIN}", caller?.PlayerName == null ? "Console" : caller.PlayerName).Replace("{WEAPON}", weaponName.Split("_")[1])).Replace("{PLAYER}",player.PlayerName)); } private static bool GetTarget(CommandInfo command, out CCSPlayerController? player)