fixed banned weapon checking

This commit is contained in:
BuildTools
2023-12-10 01:15:52 +03:30
parent 07b79cb91a
commit a56b5f7b3f

View File

@@ -917,9 +917,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
}
string[] BannedGiveItems = {"weapon_knife_canis","weapon_falchion","weapon_flip","weapon_knife_outdoor","weapon_knife_widowmaker","weapon_elite","weapon_knife_skeleton",
"weapon_knife_push","weapon_knife_gypsy_jackknife","weapon_gut","weapon_tactical","weapon_knife_ursus","weapon_knife_stiletto","weapon_bayonet","weapon_m9_bayonet",
"weapon_karambit","weapon_butterfly","weapon_survival_bowie","weapon_knife_cord"};
[ConsoleCommand("css_give")]
[RequiresPermissions("@css/give")]
[CommandHelper(minArgs: 2, usage: "<#UserId Or Name> <WeaponName>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
@@ -928,13 +925,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
if(!GetTarget(command, out var player) || player == null || !player.IsValid) return;
string weaponName = command.GetArg(2);
//check if weapon is inside the bannedItems
foreach(string bannedWeapon in BannedGiveItems){
if(bannedWeapon.Equals(weaponName.ToLower())){
//check if weapon is knife
if(weaponName.Contains("knife") || weaponName.Contains("bayonet")){
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));