mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-23 04:00:38 +00:00
Added a check for knifes
This commit is contained in:
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"discord.removeDetails": false,
|
||||||
|
"discord.removeLowerDetails": false,
|
||||||
|
"discord.removeRemoteRepository": true
|
||||||
|
}
|
||||||
@@ -916,18 +916,28 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
Logger.LogInformation($"{caller!.PlayerName} executed command ({command.ArgString}).");
|
Logger.LogInformation($"{caller!.PlayerName} executed command ({command.ArgString}).");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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")]
|
[ConsoleCommand("css_give")]
|
||||||
[RequiresPermissions("@css/give")]
|
[RequiresPermissions("@css/give")]
|
||||||
[CommandHelper(minArgs: 2, usage: "<#UserId Or Name> <WeaponName>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
[CommandHelper(minArgs: 2, usage: "<#UserId Or Name> <WeaponName>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
public void OnGiveCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnGiveCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!GetTarget(command, out var player) || player == null || !player.IsValid) return;
|
if(!GetTarget(command, out var player) || player == null || !player.IsValid) return;
|
||||||
|
string weaponName = command.GetArg(2);
|
||||||
|
|
||||||
string weapon = command.GetArg(2);
|
//check if weapon is inside the bannedItems
|
||||||
player.GiveNamedItem(weapon);
|
foreach(string bannedWeapon in BannedGiveItems){
|
||||||
|
if(bannedWeapon.Equals(weaponName.ToLower())){
|
||||||
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));
|
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)
|
private static bool GetTarget(CommandInfo command, out CCSPlayerController? player)
|
||||||
|
|||||||
Reference in New Issue
Block a user