How to remove blips and bodies of dead peds? [C#]
-
I am unsure of how to get rid of the dead bodies of peds I have spawned (Such as a bodyguard) and how to delete the blip. I am new to scripting and c# and have searched around but couldn't find much about it. Here is something I have tried:
EDIT: https://imgur.com/lR1gX2u (screenshot of the code instead)public void removeDeadEntity()
{
if (spawnedPedList.Count != 0)
{
for(int i = 0; i <spawnedPedList.Count; i++)
{
if (spawnedPedList[i] == null || !spawnedPedList[i].Exists())
{
spawnedPedList.RemoveAt(i);
i--;
continue;
}
if (spawnedPedList[i].IsDead)
{
Interval = 10000;
spawnedPedList[i].Delete();
spawnedPedList.RemoveAt(i);
i--;
}
}
}
}But whenever it gets rid of the bodies and blips but whenever they die they just disappear instantly and I then I can no longer open my menu until I reload the script. I have also tried using if(Ped.IsDead) and blip.remove() etc, but I can't get it to work. So maybe some samples or some help would be appreciated. Thanks!
-
I have just tried this but it doesn't remove the blip:
void RemoveBodyguard()
{
if(bodyguard.IsDead)
{
if(bodyguard.CurrentBlip.Exists())
{
bodyguard.CurrentBlip.Remove();
}
}
}