Merge pull request #9 from DEADLYDEVIL-IR/main

Added CSS_GIVE
This commit is contained in:
Dawid Bepierszcz
2023-12-10 15:28:17 +01:00
committed by GitHub
4 changed files with 22 additions and 1 deletions

3
.gitignore vendored
View File

@@ -1,4 +1,5 @@
bin/
obj/
.vs/
.git
.git
.vscode/

View File

@@ -917,6 +917,23 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
}
[ConsoleCommand("css_give")]
[RequiresPermissions("@css/give")]
[CommandHelper(minArgs: 2, usage: "<#UserId Or Name> <WeaponName>", 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 bool GetTarget(CommandInfo command, out CCSPlayerController? player)
{

View File

@@ -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 <steamid> [time in minutes/0 perm] [reason] - Ban player via steamid64\n" +
"- css_banip <ip> [time in minutes/0 perm] [reason] - Ban player via IP address\n- css_unban <steamid or name or ip> - Unban player\n" +

View File

@@ -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 <cvar> <value> - Change cvar value // @css/cvar
- css_rcon <command> - Run command as server // @css/rcon
- css_give <#userid or name> <WeaponName> - Gives a weapon to a Player // @css/give
- @Message - Say message to all admins // @css/chat
```