mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-10-18 21:07:04 +02:00
Merge branch 'main' of https://github.com/Cruze03/CS2-SimpleAdmin
This commit is contained in:
commit
a3dccbaa1e
19 changed files with 235 additions and 33 deletions
|
|
@ -67,18 +67,11 @@ public partial class CS2_SimpleAdmin
|
|||
var weaponName = command.GetArg(2);
|
||||
|
||||
// check if item is typed
|
||||
if (weaponName.Length < 5)
|
||||
{
|
||||
command.ReplyToCommand($"No weapon typed.");
|
||||
return;
|
||||
}
|
||||
|
||||
// check if item is valid
|
||||
if (!weaponName.Contains("weapon_") && !weaponName.Contains("item_"))
|
||||
{
|
||||
command.ReplyToCommand($"{weaponName} is not a valid item.");
|
||||
return;
|
||||
}
|
||||
// if (weaponName.Length < 2)
|
||||
// {
|
||||
// command.ReplyToCommand($"No weapon typed.");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// check if weapon is knife
|
||||
if (weaponName.Contains("_knife") || weaponName.Contains("bayonet"))
|
||||
|
|
@ -105,9 +98,22 @@ public partial class CS2_SimpleAdmin
|
|||
|
||||
// Set default caller name if not provided
|
||||
callerName ??= caller != null ? caller.PlayerName : _localizer?["sa_console"] ?? "Console";
|
||||
var weapons = WeaponHelper.GetWeaponsByPartialName(weaponName);
|
||||
|
||||
switch (weapons.Count)
|
||||
{
|
||||
case 0:
|
||||
return;
|
||||
case > 1:
|
||||
{
|
||||
var weaponList = string.Join(", ", weapons.Select(w => w.EnumMemberValue));
|
||||
command?.ReplyToCommand($"Found weapons with a similar name: {weaponList}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Give weapon to the player
|
||||
player.GiveNamedItem(weaponName);
|
||||
player.GiveNamedItem(weapons.First().EnumValue);
|
||||
|
||||
// Log the command
|
||||
if (command == null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue