Don't forget left over living or dead horses.
'>
That is if you are using horses...
//Script Name: ag_area_clean (Horse Edition)
//////////////////////////////////////////
//Created by: Alan_Guile
//Modified By: Genisys (Guile) <<< Not Alan Guile
//Modified On: 9/17/08
/////////////////////////////////////////
/*
This script goes in the OnExit event
for all areas within your module, if
you want to clean inventories of placeable
objects, in some areas I suggest you save
this under a new name FIRST!
This script destroys all horses which are
not assigned to a PC left in the area
IF there are no more PCs in the area the
script will fire.
*/
////////////////////////////////////////
//Required Horse Include
#include "x3_inc_horse"
////////////////////////////////////////
//OPTIONS/////
//Note: This is a very important script, it should go on the exit event of
//all area you create. (with some exceptions) This reduces lagg too!
//IMPORTANT: If you change this option change the script name! (Save As)
// Set this to TRUE if you want placeable object's inventories cleared
int nClearPlaceInv = FALSE;
// Set the amount of time to wait for cleaning here in seconds
float fDelayTime = 5.0;
/////////////////WARNING: DON'T TOUCH ANYTHING BELOW!!!////////////
void CleanArea(object oArea)
{
object oTrash = GetFirstObjectInArea(oArea);
object oInvItem;
//Check for PCs
object oPC = GetFirstPC();
while (GetIsObjectValid(oPC)) {
if(!GetIsDM(oPC)||!GetIsDMPossessed(oPC))
{
if (GetArea(oPC) == oArea) {
DeleteLocalInt(oArea, "CleanArea");
return;
}
}
oPC = GetNextPC();
}
while(GetIsObjectValid(oTrash)) {
string sTag = GetTag(oTrash);
string sTagPrefix = GetStringLeft(GetTag(oTrash), 15);
// Clear remains, dropped items
if(GetObjectType(oTrash)==OBJECT_TYPE_ITEM ||
sTag == "drow_ass" ||
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(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) ||
sTag == "drow_ass" ||
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);
}
DeleteLocalInt(oArea, "CleanArea");
}
void main()
{
object oArea = OBJECT_SELF;
object oPC = GetExitingObject();
if (!GetIsPC(oPC)) return;
if (GetLocalInt(oArea, "CleanArea") != 1)
{
DelayCommand(fDelayTime, CleanArea(oArea));
SetLocalInt(oArea, "CleanArea", 1);
}
}
Modifié par _Guile, 10 avril 2011 - 06:01 .