Skip to content

Commit

Permalink
Possibly fixed NRE on customrole give command (#2754)
Browse files Browse the repository at this point in the history
* Re-added customrole and customitem commands.

* fix stylecop momento

* Possible fix for cr give NRE

* Possibly fixed NRE on customrole give command.

---------

Co-authored-by: Nao <[email protected]>
  • Loading branch information
Monaldcry7788 and NaoUnderscore authored Jul 26, 2024
1 parent ed9b58e commit a9e9045
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions Exiled.CustomModules/API/Commands/CustomRoles/Give.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace Exiled.CustomModules.API.Commands.CustomRoles
using Exiled.CustomModules.API.Features;
using Exiled.CustomModules.API.Features.CustomRoles;
using Exiled.Permissions.Extensions;
using RemoteAdmin;

/// <summary>
/// The command to give a role to player(s).
Expand Down Expand Up @@ -67,17 +66,17 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s

if (arguments.Count == 1)
{
if (sender is PlayerCommandSender playerCommandSender)
{
Pawn player = Player.Get(playerCommandSender).Cast<Pawn>();
Pawn player = Player.Get(arguments.At(1)).Cast<Pawn>();

role.Spawn(player);
response = $"{role.Name} given to {player.Nickname}.";
return true;
if (player is null)
{
response = "Player not found";
return false;
}

response = "Failed to provide a valid player.";
return false;
role.Spawn(player);
response = $"{role.Name} given to {player.Nickname}.";
return true;
}

string identifier = string.Join(" ", arguments.Skip(1));
Expand Down

0 comments on commit a9e9045

Please sign in to comment.