diff --git a/.gitignore b/.gitignore index 48166c1..6822e32 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ bin/ obj/ .vs/ -.git \ No newline at end of file +.git +.vscode/ \ No newline at end of file diff --git a/CS2-SimpleAdmin.cs b/CS2-SimpleAdmin.cs index cf8dd24..3bf9c1c 100644 --- a/CS2-SimpleAdmin.cs +++ b/CS2-SimpleAdmin.cs @@ -1382,6 +1382,23 @@ 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); + + //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)); + } private static TargetResult? GetTarget(CommandInfo command) { diff --git a/README.md b/README.md index 20fbc1f..3727f59 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ Manage your Counter-Strike 2 server by simple commands :) - css_respawn <#userid or name> - Respawn player // @css/cheats - css_cvar - Change cvar value // @css/cvar - css_rcon - Run command as server // @css/rcon +- css_give <#userid or name> - Gives a weapon to a Player // @css/give - team_chat @Message - Say message to all admins // @css/chat ```