I use to use the old script "ag_area_clean" created by Allen Guile on the old Paths of Ascension Module, however, I felt like it was outdated, because sometimes, when a PC logged out the area would stay spawned... (Major Lagg!)
So, I created a new area clean script specifically for hostile areas (or Areas Where Monsters Spawn)
This Script goes on the OnEnter Event of an Area... (make sure this is good)
//scriptname: check_area_oe
///////////////////////////////////////////
//Created by: Genisys (Guile)
//Created On: 7/18/2010
///////////////////////////////////////////
/* ///NOTES///
When a PC enters an area, this script will
check to see first if the area has been
cleaned (empty), if not, it will start
checking every X minutes (Set Below)
to verify the area is in fact clean,
IF NO PCs are Present ONLY!
*/
///////////////////////////////////////////
//////IMPORTANT SETTING//////////
//Set this to how often you wish the
//script to fire to check the area..
//This script refires itself (While active)
float CHECK_INTERVAL = 60.0; //Default = 60.0 (60 seconds / or 1 Minute)
//////////////////////////////////////////
//Main Script
void main()
{
object o = GetEnteringObject();
object oArea = GetArea(o);
int nCheck = GetLocalInt(oArea, "CLEAN_CHECK");
//
if(!GetIsPC(o) || GetIsDM(o) || GetIsDMPossessed(o))
{ return; } //Stop the whole script if it's NOT a Player entering..
//
if(nCheck != TRUE) //If this is our first time checking the area...
{
SetLocalInt(oArea, "CLEAN_CHECK", TRUE); //Set that we are checking the area
//Start the checking process now..
DelayCommand(CHECK_INTERVAL, ExecuteScript("check_area_spawn", oArea));
}
//
//
//End Void Main Script
}
And This script is the script that is fired by the above script (On the area that started the firing of this script)
(Please make sure there are no errors in this script either, to verify we have a great script to use, all of us)
//scriptname: check_area_spawn
///////////////////////////////////////////
//Created by: Genisys (Guile)
//Created On: 7/18/2010
///////////////////////////////////////////
/* ///NOTES///
This script is fired from the script
"area_check_oe" which basically is
a looping script which fires this script
every so often to verify the area is
in fact clean, to prevent lagg!
*/
///////////////////////////////////////////
//Important Settings
//
//Set this to TRUE if you want to remove all items in
//PLACEABLE OBJECTS (Remains dropped by monsters are always cleaned)
const int nClearPlaceInv = FALSE; //Default = FALSE (Don't clean inventories)
//
//Set the float below to the amount of time (in seconds) you want the
//Area to recheck to see if the PCs are gone.. (To begin cleaning the area)
const float CHECK_INTERVAL = 60.0; // Default = 60.0 (60 seconds or 1 minute)
//
////////////////////////////////////////
////////////////////////////////////////////////////////
//////WARNING: DON'T TOUCH ANYTHING BELOW THIS LINE!!!!
///////////////////////////////////////////////////////
///////////////////////////////////////
//Required Horse Include
#include "x3_inc_horse"
//
//Declare Prototypes
int nPC(object oArea);
void CleanArea(object oArea);
//
//Main Script
void main()
{
object oArea = OBJECT_SELF;
int nA = nPC(oArea); //Is a PC Present?
//
//If no PCs are in the area, clean it!
if(nA == FALSE)
{
CleanArea(oArea);
SetLocalInt(oArea, "CLEAN_CHECK", FALSE);//Tell the first script area is clean!
}
else
{
//Otherwise continue to loop this script till area is clean..
//This is set to 60 seconds, you can increase this..
DelayCommand(CHECK_INTERVAL, ExecuteScript("check_area_spawn", OBJECT_SELF));
}
//
//Main Script End
}
//
//Define Prototype
int nPC(object oArea)
{
object oMon;
int nType;
int a = TRUE; //Tell the script here is NO PC Present, clean the area!
//
oMon = GetFirstObjectInArea(oArea);
while(GetIsObjectValid(oMon))
{
if(GetIsPC(oMon))
{
a = FALSE; //A PC is present, DON'T CLEAN THE AREA YET!
}
oMon = GetNextObjectInArea(oArea);
}
return a; //Tell the main script what to do..
//
//Main Script End
}
//
//////////////////////////////////////////////////////////////////
//Prototype
//Custom Function for cleaning up the area, taken from ag_area_clean
//Created by Allen Guile from the AW Team from Paths of Ascension
void CleanArea(object oArea)
{
object oTrash = GetFirstObjectInArea(oArea);
object oInvItem;
//
while(GetIsObjectValid(oTrash))
{
string sTag = GetTag(oTrash);
string sTagPrefix = GetStringLeft(GetTag(oTrash), 15);
// Clear remains, dropped items ALWAYS
if(GetObjectType(oTrash)==OBJECT_TYPE_ITEM ||
GetStringLowerCase(GetName(oTrash)) == "remains")
{
AssignCommand(oTrash, SetIsDestroyable(TRUE));
if (GetHasInventory(oTrash))
{
oInvItem = GetFirstItemInInventory(oTrash);
while(GetIsObjectValid(oInvItem))
{
DestroyObject(oInvItem,0.0);
oInvItem = GetNextItemInInventory(oTrash);
}
}
else DestroyObject(oTrash, 0.0);
}
//
// Clear placeable inventories(IF Set to do so at the top of script)
if(GetObjectType(oTrash)==OBJECT_TYPE_PLACEABLE &&
nClearPlaceInv == TRUE)
{
if (GetHasInventory(oTrash))
{
object oInvItem = GetFirstItemInInventory(oTrash);
while(GetIsObjectValid(oInvItem))
{
DestroyObject(oInvItem,0.0);
oInvItem = GetNextItemInInventory(oTrash);
}
}
}
//
else if (GetIsEncounterCreature(oTrash) ||
sTagPrefix == "PWFSE_SPAWNERID")
{
AssignCommand(oTrash, SetIsDestroyable(TRUE));
DestroyObject(oTrash, 0.0);
}
//
// If it's a mountable creature!
else if (HorseGetIsAMount(oTrash))
{
//If the mount has no master!
if(HorseGetOwner(oTrash)== OBJECT_INVALID)
{
AssignCommand(oTrash, SetIsDestroyable(TRUE));
DestroyObject(oTrash, 0.0);
}
}
//
//
oTrash = GetNextObjectInArea(oArea);
}
//
//Prototype End
}
Thanks a bunch 4 your help.
EDITED: Revised 7_23_2010 = Finished & Tested Script
Modifié par Genisys, 24 juillet 2010 - 01:16 .