Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions EXILED/Exiled.CustomItems/Commands/Give.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ namespace Exiled.CustomItems.Commands
using Exiled.Permissions.Extensions;

using RemoteAdmin;
using UnityStandardAssets.Effects;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

using Utils;

/// <summary>
/// The command to give a player an item.
Expand Down Expand Up @@ -97,27 +99,32 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
response = $"Custom item {item?.Name} given to all players who can receive them ({eligiblePlayers.Count} players)";
return true;
default:
if (Player.Get(identifier) is not { } player)
{
response = $"Unable to find player: {identifier}.";
return false;
}
break;
}

if (!CheckEligible(player))
{
response = "Player cannot receive custom items!";
return false;
}
IEnumerable<Player> list = Player.GetProcessedData(arguments, 1);

if (list.IsEmpty())
{
response = "Cannot find player! Try using the player ID!";
return false;
}

foreach (Player player in list)
{
if (CheckEligible(player))
{
item?.Give(player);
response = $"{item?.Name} given to {player.Nickname} ({player.UserId})";
return true;
}
}

response = $"{item?.Name} given to {list.Count()} players!";
return true;
}

/// <summary>
/// Checks if the player is eligible to receive custom items.
/// </summary>
private bool CheckEligible(Player player) => player.IsAlive && !player.IsCuffed && (player.Items.Count < 8);
}
}
}
27 changes: 18 additions & 9 deletions EXILED/Exiled.CustomRoles/Commands/Give.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace Exiled.CustomRoles.Commands
using Exiled.Permissions.Extensions;

using RemoteAdmin;
using Utils;

/// <summary>
/// The command to give a role to player(s).
Expand Down Expand Up @@ -96,16 +97,24 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
ListPool<Player>.Pool.Return(players);
return true;
default:
if (Player.Get(identifier) is not Player ply)
{
response = $"Unable to find a player: {identifier}";
return false;
}

role.AddRole(ply);
response = $"{role.Name} given to {ply.Nickname}.";
return true;
break;
}

IEnumerable<Player> list = Player.GetProcessedData(arguments, 1);
if (list.IsEmpty())
{
response = "Cannot find player! Try using the player ID!";
return false;
}

foreach (Player player in list)
{
role.AddRole(player);
}

response = $"Customrole {role.Name} given to {list.Count()} players!";

return true;
}
catch (Exception e)
{
Expand Down