C# Mono V2 - Next Skinning : Pelt remove

Hey everyone,

I’m working on a RedM RP server and I’m currently fine-tuning the skinning system. After skinning an animal, the player picks up the pelt as a carry prop. Once the animation finishes, I want to automatically remove the pelt object from the game world.

Initially, I used this logic:

  if (Natives.IsPedCarryingSomething(playerPed) == 1)
{
      int attachedEntity = Natives.GetEntityAttachedTo(playerPed);

      if (Natives.DoesEntityExist(attachedEntity))
     {
             Natives.DetachEntity(attachedEntity, true, true);
             Natives.DeleteEntity(ref attachedEntity);
      }
}

This works if the player is still holding the pelt, but it fails when they throw/drop

Here are some alternative solutions I’m considering:

  1. Prevent the loot prop from being created at all (but i don’t find a solution or a way to do that).
  2. Scan the area for skins after every loot interaction automatically to clear leftovers

I just would like to discuss about the best way.
Thanks

You can probably fix this by using SetEntityAsMissionEntity before trying to delete it