This is the script I use in all my stores to clear the store of item sold...
The reason we use OnOpenStore, rather than OnCloseStore, is because a PC could be viewing the store, other than the one closing it, and by doing so, they would wipe the store.. This can still happen if a PC opens the store while another PC is viewing it, but the benefit is, the PC cannot see what the PC just sold the store, so no spying..
// This script goes into OnOpenStore.
// Made by Darvin Kezar.
void main()
{
object oItem = GetFirstItemInInventory();
int nCount = GetLocalInt(OBJECT_SELF, "Count")+1;
SetLocalInt(OBJECT_SELF, "Count", nCount);
if (nCount == 1)
{
while(oItem != OBJECT_INVALID)
{
SetLocalInt(oItem, "Default", 1);
oItem = GetNextItemInInventory();
}
}
else
{
while(oItem != OBJECT_INVALID)
{
if(GetLocalInt(oItem, "Default") == 0)
DestroyObject(oItem);
oItem = GetNextItemInInventory();
}
}
}
Modifié par Genisys, 07 septembre 2010 - 05:40 .