I've been having frustrations with a spawn cleaning script that's not actually been working. I've included a message to try to debug it, but it's still not working! After 10 minutes of leaving an area, I'll get a message from every encounter creature there that they have been destroyed, but nothing actually is happening to them! It's also not completing, because ten minutes later, the script is firing again.
Obviously, the function I've created is triggering, but the Destroy Object part is not. Can anyone tell me what I'm doing wrong? Since it's only destroying Encounter Creatures, any other objects in the area are probably keeping the script looping, but that isn't explaining why things aren't dying. Also, please let me know the shortcut for putting the following script in its own textbox on the forum /nwscript or whatever:
void CleanSpawn(object oArea =OBJECT_SELF)
{
if(GetIsPCInArea( oArea))
{
return;
}
object oObject = GetFirstObjectInArea( oArea);
while( GetIsObjectValid( oObject))
{
if( GetIsEncounterCreature( oObject) && !GetPlotFlag( oObject) && !GetImmortal( oObject))
{
string sName =GetName(oObject);
DestroyObject( oObject, 0.1f);
SendMessageToAllDMs(sName+" has been destroyed by the Spawn Cleaner!");
}
oObject = GetNextObjectInArea( oArea);
}
}
// Area OnExit main function.
void main()
{
object oExiting = GetExitingObject();
object oExplore= OBJECT_SELF;
//if( !GetIsObjectValid( oExiting)) return;
// Schedule the area cleaner.
ExploreAreaForPlayer(oExplore, oExiting);
DelayCommand(610.0, CleanSpawn());
}