From 59975bb49d94ba623d41d618d70c76d30c8e7e81 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sat, 9 Dec 2023 10:43:33 +0330 Subject: [PATCH 1/7] Add the css_give command and add in README.MD --- CS2-SimpleAdmin.cs | 12 ++++++++++++ Config.cs | 2 ++ README.md | 1 + 3 files changed, 15 insertions(+) diff --git a/CS2-SimpleAdmin.cs b/CS2-SimpleAdmin.cs index 53b47b5..e442a10 100644 --- a/CS2-SimpleAdmin.cs +++ b/CS2-SimpleAdmin.cs @@ -916,7 +916,19 @@ 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 weapon = command.GetArg(2); + player.GiveNamedItem(weapon); + + Server.PrintToChatAll(Helper.ReplaceTags($" {Config.Prefix} {Config.Messages.AdminChangeMap}".Replace("{ADMIN}", caller?.PlayerName == null ? "Console" : caller.PlayerName).Replace("{WEAPON}", weapon))); + } private static bool GetTarget(CommandInfo command, out CCSPlayerController? player) { diff --git a/Config.cs b/Config.cs index d9210b3..cd76a34 100644 --- a/Config.cs +++ b/Config.cs @@ -41,6 +41,8 @@ namespace CS2_SimpleAdmin public string AdminRespawnMessage { get; set; } = "Admin {ADMIN} respawned {PLAYER}!"; [JsonPropertyName("AdminSayPrefix")] public string AdminSayPrefix { get; set; } = "{RED}ADMIN: {DEFAULT}"; + [JsonPropertyName("AdminGiveMessage")] + public string AdminGiveMessage { get; set; } = "Admin {ADMIN} Gave {PLAYER} a {WEAPON}!"; [JsonPropertyName("AdminHelpCommand")] public string AdminHelpCommand { get; set; } = "{GREEN}[ CS2-SimpleAdmin HELP ]{DEFAULT}\n- css_ban <#userid or name> [time in minutes/0 perm] [reason] - Ban player\n- css_addban [time in minutes/0 perm] [reason] - Ban player via steamid64\n" + "- css_banip [time in minutes/0 perm] [reason] - Ban player via IP address\n- css_unban - Unban player\n" + diff --git a/README.md b/README.md index 083d7d1..f5e5c8a 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ It's only plugin base, I don't have much time for more extensive development, so - 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/cheats - @Message - Say message to all admins // @css/chat ``` From b8048e1500dcb0dec8b93fa1e329f8081914462a Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sat, 9 Dec 2023 10:49:19 +0330 Subject: [PATCH 2/7] Fixed server printing map instead of given weapon --- CS2-SimpleAdmin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CS2-SimpleAdmin.cs b/CS2-SimpleAdmin.cs index e442a10..7e4fc0b 100644 --- a/CS2-SimpleAdmin.cs +++ b/CS2-SimpleAdmin.cs @@ -927,7 +927,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig Date: Sat, 9 Dec 2023 10:53:13 +0330 Subject: [PATCH 3/7] fixed writing player name after giving waepon in chat --- CS2-SimpleAdmin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CS2-SimpleAdmin.cs b/CS2-SimpleAdmin.cs index 7e4fc0b..c01bd29 100644 --- a/CS2-SimpleAdmin.cs +++ b/CS2-SimpleAdmin.cs @@ -927,7 +927,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig Date: Sat, 9 Dec 2023 10:58:21 +0330 Subject: [PATCH 4/7] changed permissions to @css/give --- CS2-SimpleAdmin.cs | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CS2-SimpleAdmin.cs b/CS2-SimpleAdmin.cs index c01bd29..a263433 100644 --- a/CS2-SimpleAdmin.cs +++ b/CS2-SimpleAdmin.cs @@ -917,7 +917,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig ", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)] public void OnGiveCommand(CCSPlayerController? caller, CommandInfo command) { diff --git a/README.md b/README.md index f5e5c8a..af477b7 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ It's only plugin base, I don't have much time for more extensive development, so - 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/cheats +- css_give <#userid or name> - Gives a weapon to a Player // @css/give - @Message - Say message to all admins // @css/chat ``` From 07b79cb91a720db09a83cf9df32fa7c004ba439b Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sun, 10 Dec 2023 00:56:30 +0330 Subject: [PATCH 5/7] Added a check for knifes --- .vscode/settings.json | 5 +++++ CS2-SimpleAdmin.cs | 20 +++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 .vscode/settings.json 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) From a56b5f7b3f2ca85595c77560518eabedd00ff9bb Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sun, 10 Dec 2023 01:15:52 +0330 Subject: [PATCH 6/7] fixed banned weapon checking --- CS2-SimpleAdmin.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/CS2-SimpleAdmin.cs b/CS2-SimpleAdmin.cs index c178296..525444b 100644 --- a/CS2-SimpleAdmin.cs +++ b/CS2-SimpleAdmin.cs @@ -917,9 +917,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig ", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)] @@ -928,13 +925,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig Date: Sun, 10 Dec 2023 01:33:59 +0330 Subject: [PATCH 7/7] fixed weapon checking --- .gitignore | 3 ++- .vscode/settings.json | 5 ----- CS2-SimpleAdmin.cs | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) delete mode 100644 .vscode/settings.json 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/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index f2fe8c8..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "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 525444b..b6d6764 100644 --- a/CS2-SimpleAdmin.cs +++ b/CS2-SimpleAdmin.cs @@ -926,7 +926,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig