OnStoreClosed

From NWN Lexicon
Jump to navigationJump to search

The script attached to this event occurs when the store a PC is currently using is closed. Perhaps use in a multiplayer environment to clean up gross amounts of sold items, or change the stock, although note in multiplayer multiple players may have a store open at once.


Trigger

When a store in use by a PC is closed.


Function(s)

GetLastClosedBy() returns the last PC to close the store. In a multiplayer setting others may still have it open however.


Remarks

By default no script is attached to this event.

Stores reorder their stock pages - ie sort by item type - when an item is added to a store by a player or script (eg CreateObject). They are not reordered when things are removed (brought) from the store. If you want to rearrange items back to default you could add a single item, although note the processing time for sorting very large stores is pretty slow, being around O(n^2) speed (where n is the number of items already in that page).


Example

// When this store is closed, it is actually destroyed. One time 
// deals have a new meaning now, given you cannot open stores
// which are not there.

void main()
{
    // Store closed
    DestroyObject(OBJECT_SELF);
}

See Also

functions: 

GetLastClosedBy()