Code: Select all
foreach (var o in Game.GetObjects<IObject>().Where(o => o.Name == "Lamp00"))
{
// If you comment this line, the code that runs in the next 5 seconds will work
o.DealDamage(o.GetHealth());
}
// Run after 5 seconds
ScriptHelper.Timeout(() =>
{
foreach (var o in Game.GetObjects<IObject>().Where(o => o.Name == "Lamp00"))
{
o.Remove();
}
}, 5000);