ShowOff:OnPreActivateInventoryItem

From GECK
Jump to: navigation, search

An event handler added by the ShowOff NVSE Plugin version 1.50.

Description

This event runs before an item in the player's inventory is activated. Accounts for item activation via hotkeys.

If the function returns false (0) via SetFunctionValue, then activation for that item is prevented.

  • Since multiple handlers can be set for the event, it only takes a minimum of 1 handler to return false for activation to be prevented.
  • If SetFunctionValue is NOT called, or if it is set with a non-zero value, then the handler will not prevent activation.

The calling reference will always be the player.

The 1st UDF arg is the item BaseForm, while the 2nd is an Inventory Reference of the item.

The 3rd arg, bIsActivationNotPrevented, informs if activation would already be prevented by a handler that ran just before.

If the item was activated via hotkey press, iActivatedHotkey is the number of that hotkey. Otherwise, it is 0.

Syntax

Use SetEventHandler / SetEventHandlerAlt with the event name "ShowOff:OnPreActivateInventoryItem".

Handler Script

A skeleton handler script for this event:

scn OnPreActivateInventoryItemUDF

ref rBaseItem
ref rInvRef
short bIsActivationNotPrevented
int iActivatedHotkey

begin Function { rBaseItem, rInvRef, bIsActivationNotPrevented, iActivatedHotkey }

    ; GetSelf = player

    printvar rBaseItem
    printvar rInvRef
    printvar bIsActivationNotPrevented 
    printvar iActivatedHotkey

    SetFunctionValue 0  ;prevent the item from being activated (equipped/unequipped, or ingested).
    print "OnPreActivateInventoryItemUDF >> RAN!"

end

Example

SetEventHandlerAlt "ShowOff:OnPreActivateInventoryItem" OnPreActivateInventoryItemUDF

Will run whenever any item is activated in the player's inventory.

SetEventHandlerAlt "ShowOff:OnPreActivateInventoryItem" OnPreActivateInventoryItemUDF 1::Stimpack

Will run whenever a stimpack is about to be used by the player.

SetEventHandlerAlt "ShowOff:OnPreActivateInventoryItem" OnPreActivateInventoryItemUDF "priority"::2
SetEventHandlerAlt "ShowOff:OnPreActivateInventoryItem" OnPreActivateInventoryItemUDF "priority"::1 3::1

The first handler will run before the second, because it has a higher priority. When the first handler runs, it will prevent activation. After that, the second handler tries to get dispatched, but the 3rd filter, bIsActivationNotPrevented, is not equal to 1 due to the effects of the first handler, so it doesn't get dispatched.

See Also