OnAcquireItem

The script attached to this event fires when an item is acquired. The item can be tested against a list of items, and if the item is found an event could occur such as the corpses around the PC arising to fight them in undeath or a journal entry is made. It also fires whenever the OnClientEnter script would fire for a PC. It fires before the OnClientEnter Event starts, for all the items in the PC's inventory (including those equipped!) This is new, quite recent behavior change for this event.


Trigger

Whenever an item is added to someone's inventory.


Function(s)

GetModuleItemAcquired() returns the item that was just acquired (and caused this event to fire).
GetModuleItemAcquiredFrom() to return the object that the item was acquired or taken from.
GetModuleItemAcquiredBy() to return the object that aquired the item. (Note: GetItemPossessor(oItem) will perform the same thing)
GetModuleItemAcquiredStackSize() returns the amount of items added to an exsisting stack.


Remarks

Since GetModuleItemAcquiredStackSize() returns the change in stack sizes if something is added to an exsisting stack, it will fire for when a PC picks up a potion and it is adding to an exsisting stack of potions. If GetModuleItemAcquiredFrom() is invalid, it could have been from a Barter screen or the ground. Pickpocketed items do trigger the module events, and such stolen items are automatically marked as stolen - retrievable by GetStolenFlag(object oItem).


Known Bugs

This event does not fire when a PC picks up gold.


Example

// Writes an entry in the logfile whenever a PC acquires an
// item, if the script is put OnAcquireItem. The entry will
// contain info about the PC acquiring the item, the item,
// and the object the item was acquired from
void main()
{
     object oItem = GetModuleItemAcquired();
     object oPC = GetModuleItemAcquiredBy();
     // Note: you can use GetItemPossessor(oItem); to get oPC
     object oLostBy = GetModuleItemAcquiredFrom();

     string sLog = GetName(oPC) + " acquired " + GetName(oItem) + " from " + GetName(oLostBy);
     PrintString(sLog);
}

See Also

Objects with Events | Module
functions: GetItemPossessor | GetModuleItemAcquired | GetModuleItemAcquiredBy | GetModuleItemAcquiredFrom | GetModuleItemAcquiredStackSize