Skip to content

Commit

Permalink
Added a parameter for people to optionally remove the entity when cal…
Browse files Browse the repository at this point in the history
…ling RemoveItemByDesignerName (#214)
  • Loading branch information
B3none authored Dec 24, 2023
1 parent ca85922 commit d527038
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion managed/CounterStrikeSharp.API/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public static TargetResult ProcessTargetString(string pattern, CCSPlayerControll
}

public static bool RemoveItemByDesignerName(this CCSPlayerController player, string designerName)
{
return RemoveItemByDesignerName(player, designerName, false);
}

public static bool RemoveItemByDesignerName(this CCSPlayerController player, string designerName, bool shouldRemoveEntity)
{
CHandle<CBasePlayerWeapon>? item = null;
if (player.PlayerPawn.Value == null || player.PlayerPawn.Value.WeaponServices == null) return false;
Expand All @@ -90,9 +95,15 @@ public static bool RemoveItemByDesignerName(this CCSPlayerController player, str
item = weapon;
}

if(item != null && item.Value != null)
if (item != null && item.Value != null)
{
player.PlayerPawn.Value.RemovePlayerItem(item.Value);

if (shouldRemoveEntity)
{
item.Value.Remove();
}

return true;
}

Expand Down

0 comments on commit d527038

Please sign in to comment.