From 501f92af7332f8a69451f332248541c8d33a7bcb Mon Sep 17 00:00:00 2001 From: Lennart Kampshoff Date: Wed, 19 Sep 2018 14:19:11 +0200 Subject: [PATCH] Add /giveweapon command --- Server/Commands/Admin.cs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Server/Commands/Admin.cs b/Server/Commands/Admin.cs index 2f0dd635..1a16b7b8 100644 --- a/Server/Commands/Admin.cs +++ b/Server/Commands/Admin.cs @@ -144,5 +144,38 @@ namespace reallife_gamemode.Server.Commands player.SendChatMessage("~m~Benutzung: ~s~/ipl [Load / Remove] [Name]"); } } + + [Command("giveweapon", "~m~Benutzung: ~s~/giveweapon [Spieler] [Waffe] [Munition]")] + public void CmdAdminGiveweapon(Client player, string name, string weapon, int ammo) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + if (ammo <= 0) + { + player.SendChatMessage("~r~[FEHLER]~s~ Es muss mindestens 1 Munition vergeben werden."); + return; + } + + Client target = ClientService.GetClientByName(name); + if (target == null) + { + ChatService.PlayerNotFound(target); + return; + } + + WeaponHash wHash = NAPI.Util.WeaponNameToModel(weapon); + + if(wHash == default(WeaponHash)) + { + player.SendChatMessage("~r~[FEHLER]~s~ Diese Waffe existiert nicht."); + return; + } + + target.GiveWeapon(wHash, ammo); + } } }