when useing StoreCampaignObject funtion with stores I seem to be getting either the objects are invalid or they are valid yet no DB writen with the following script. I am tired and it is 15 mins tell christmas perhaps i should stop for the night...
//:: Script Name: zz_clr_store
//::
//:: Orginal Authors: Idea , TritonX "pshop_OnOpenDialogue"
//:: Script created by Old Man`s Beard, June 2006
//:: Thanks to Lex and UOAbigail for their support
//::
//:: EDITED/ALTERED: Greyfort
//::
//:: Created: 12.24.2010
//::
//:: Script Function:
//:: transfer store1 DB info to store2 haveing 0 duplicates
//:: from store1 into store2. Then clean out store1 db
//::
////////////////////////////////////////////////////////////////////////////////
/* //uncoment these if you dont have the include and remove the include line
//:://///////////////////////////////////////////////////////////
// Use to load a stores data base with nwn db
void OHS_LoadStore(object oStore, string sDBName);
void OHS_LoadStore(object oStore, string sDBName)
{
location lStore = GetLocation(oStore);
int bLoaded = GetLocalInt(oStore,"OHS_STORE_LOADED");
if (GetIsObjectValid(oStore) && !bLoaded)
{
int nItems = GetCampaignInt(sDBName,"N_ITEMS");
PrintString(IntToString(nItems)+" in "+sDBName);
object oItem;
int ILRStackSize, nChargesStarting;
int nNth;
for (nNth=1; nNth<=nItems; nNth++)
{
oItem = RetrieveCampaignObject(sDBName,"ITEM_"+IntToString(nNth),GetLocation(oStore),oStore);
if (GetPlotFlag(oItem) )// || GetStolenFlag(oItem)) remove // to Destroy Plot and Stolen Items
{
DestroyObject(oItem);
}
else
{
ILRStackSize = StringToInt(Get2DAString("baseitems","ILRStackSize",GetBaseItemType(oItem)));
SetItemStackSize(oItem,ILRStackSize);
nChargesStarting = StringToInt(Get2DAString("baseitems","ChargesStarting",GetBaseItemType(oItem)));
if (nChargesStarting>0) SetItemCharges(oItem,nChargesStarting);
// SetInfiniteFlag(oItem,TRUE); //Uncomment if you want stackable to be infinite
}
}
SetLocalInt(oStore,"OHS_STORE_LOADED",TRUE);
}
}//needed end of function
///////////////////////////////////////////////////////////////////////////////
*/ //uncoment these if you dont have the include and remove the include line
// includes here //
#include "zz_store_inc"
void main()
{
// this script is executed by a NPC
// NPC Stationary merchant Executing script, store and DB tag
object oNPC_Merch=OBJECT_SELF;//GetObjectByTag("stat_merch");
//debug line
PrintString(GetTag(oNPC_Merch)+" executing script");
//debug line
if (GetObjectType(oNPC_Merch) == OBJECT_TYPE_CREATURE && GetIsObjectValid(oNPC_Merch ) )
{
//debug line
PrintString("NPC valid in executing script");
//debug line
//Stationary merchant store and DB tag
object oStore=GetObjectByTag("stat_merch");
string sDBName="stat_merch";
string sStoreTag1=GetLocalString(OBJECT_SELF,"sStoreTag");
// Traveling merchant store and DB tag
object oStore2=GetObjectByTag("trvl_merch");
string sDBName2="trvl_merch";
string sStoreTag2=GetLocalString(OBJECT_SELF,"sTrvStoreTag");
int nItems2 = GetCampaignInt(sDBName2,"N_ITEMS");
object oItem;
object oItemChk;
int nNth = 0;//nItems2;
////////////////////////////////////////////////////
// first set items in traveling merchant db
oStore2 = GetObjectByTag("OHS_STORE");
if ( GetIsObjectValid(oStore2)==FALSE )
{
oStore2 = CreateObject(OBJECT_TYPE_STORE,"trvl_merch",GetLocation(OBJECT_SELF));
if (GetObjectType(oStore2) == OBJECT_TYPE_STORE)
{ //was(oStore, "OHS_PERSISTENT_STORE") replaced with sStoreTag
OHS_LoadStore(oStore2,sStoreTag2);
if (GetIsObjectValid(oStore2))
{
//debug line
PrintString(sDBName2+" valid saving items in inventory to DB");
//debug line
DestroyCampaignDatabase(sDBName2);
oItem = GetFirstItemInInventory(oStore2);
while (GetIsObjectValid(oItem))
{
StoreCampaignObject(sDBName2,"ITEM_"+IntToString(++nNth),oItem);
//debug line
string sItemName= GetName(oItem);
PrintString(sItemName+"= ITEM_"+IntToString(++nNth)+"saved to DB");
//debug line
oItem = GetNextItemInInventory(oStore2);
}//end of while
SetCampaignInt(sDBName2,"N_ITEMS",nNth);
}//end of if
}
}
/////////////////////////////////////////////////////////////////
// then store stationary merchants items in db
// removing any items that may be duplicates befor putting items
// in traveling merchants inventory
oStore = GetObjectByTag("OHS_STORE");
if ( GetIsObjectValid(oStore)==FALSE )
{ //replace "resrefofyourstore" by one in your palette
oStore = CreateObject(OBJECT_TYPE_STORE,"stat_merch",GetLocation(OBJECT_SELF));
if (GetObjectType(oStore) == OBJECT_TYPE_STORE)
{ //was(oStore, "OHS_PERSISTENT_STORE") replaced with sStoreTag
OHS_LoadStore(oStore,sStoreTag1);
if (GetIsObjectValid(oStore))
{
//debug line
PrintString(sDBName+" valid saving items in inventory to DB");
//debug line
oItemChk = GetFirstItemInInventory(oStore2);
while (GetIsObjectValid(oItemChk))
{
oItem = GetFirstItemInInventory(oStore);
while (GetIsObjectValid(oItem))
{
if(oItem == oItemChk)
{
DestroyObject(oItem);
}else{
StoreCampaignObject(sDBName2,"ITEM_"+IntToString(++nNth),oItem);
//debug line
string sItemName= GetName(oItem);
PrintString(sItemName+"= ITEM_"+IntToString(++nNth)+"saved to DB");
//debug line
}
oItem = GetNextItemInInventory(oStore);
}//end of while oItem
oItem = GetNextItemInInventory(oStore2);
}//end of while oItemChk
SetCampaignInt(sDBName2,"N_ITEMS",nNth);
}//end of if
}
}
// clean out NPC Stationary merchant store
//DestroyCampaignDatabase(sDBName);
// }else{PrintString("merchants invalid"); }
}else {PrintString("NPC not valid "); }
//////////////////////////////
}// end of script
If you all see what im missing please let me know...Perhaps its the campain objects? I even tried OMB loadstore etc after all thats what got me working on it LOL
MERRY CHRISTMAS!!!
Modifié par Greyfort, 25 décembre 2010 - 08:33 .