//::////////////////////////////////////////////////////////////////////////////
//::
//:: pshop_onstorclo2
//::
//:: Idea , TritonX
//:: pshop_onstoreclose
//:: Script created by Old Man`s Beard, June 06
//:: Thanks to Lex and UOAbigail for their support
//
//:: put this script on the OnStoreClose Event of your merchant.
//:: The merchant`s waypoint shall not be placed in the module,
//:: the shop is created from the blueprint. In this script a database is created
//:: with the name of the merchant`s resref.
//::
//:: EDITED/ALTERED: Greyfort with Help from FunkySwerve
//::
//:: Created: 12.24.2010/01.06.2011
//::
//:: NOTE: script has dificulty clearing first item, first time store closed
//:: but if closed again it will clear first item if it matches second.
//:: In this case happens to be a dagger...
//::
//::////////////////////////////////////////////////////////////////////////////
// includes here //
//::///////////////////////
void main()
{
//////////////////////////
// default save data
object oStore = OBJECT_SELF;
string sDBName = GetTag(oStore);
object oItem;
int nNth = 0;
///////////////////////
// duplicat check
object oItmDupChk;
string sTag, sTag2;
int nDup=0;
//
if (GetIsObjectValid(oStore))
{
DestroyCampaignDatabase(sDBName);
oItmDupChk=GetFirstItemInInventory(oStore);
while (GetIsObjectValid(oItmDupChk))
{
nDup = ++nDup;
sTag=GetTag(oItmDupChk);
SetLocalString(oStore, "item_"+IntToString(nDup)+"", sTag);
oItmDupChk= GetNextItemInInventory(oStore);
}
SetLocalInt(oStore, "MaxNumItems", nDup);
oItem = GetFirstItemInInventory(oStore);
while (GetIsObjectValid(oItem))
{
nNth=++nNth;
sTag2=GetLocalString(oStore,"item_"+IntToString(nNth+1)+"");
// check for duplicate destroy them
if (sTag2 == GetTag(oItem))
{
SetLocalInt(oItem, "Destroyed", 1);
DestroyObject(oItem);
}
// stores item from chest2 to "trvl_merch" sDBName
if (!GetLocalInt(oItem, "Destroyed"))
{
StoreCampaignObject(sDBName,"ITEM_"+IntToString(nNth),oItem);
}
oItem = GetNextItemInInventory(oStore);
}
SetCampaignInt(sDBName,"N_ITEMS",nNth);
}
// now check local strings versus inventory
///////////////////
}//end of script
ok I'm sure my logics off again Huh funky, this is suposed to check the invy for duplicates and does but gets all but the first Item. If anyone sees my error please let me know.
Also anyone Here if they have any windows mods/plugins that use the linux nwnx_strucs as descripbed in the post just above this one?
Modifié par Greyfort, 07 janvier 2011 - 07:28 .