# Method Global:RegisterGameObjectEvent [-] [+]

Registers a GameObject event handler.

    enum GameObjectEvents
    {
        GAMEOBJECT_EVENT_ON_AIUPDATE                    = 1,    // (event, go, diff)
        GAMEOBJECT_EVENT_ON_SPAWN                       = 2,    // (event, go)
        GAMEOBJECT_EVENT_ON_DUMMY_EFFECT                = 3,    // (event, caster, spellid, effindex, go) - Can return true to stop normal action
        GAMEOBJECT_EVENT_ON_QUEST_ACCEPT                = 4,    // (event, player, go, quest) - Can return true to stop normal action
        GAMEOBJECT_EVENT_ON_QUEST_REWARD                = 5,    // (event, player, go, quest, opt) - Can return true to stop normal action
        GAMEOBJECT_EVENT_ON_DIALOG_STATUS               = 6,    // (event, player, go)
        GAMEOBJECT_EVENT_ON_DESTROYED                   = 7,    // (event, go, attacker)
        GAMEOBJECT_EVENT_ON_DAMAGED                     = 8,    // (event, go, attacker)
        GAMEOBJECT_EVENT_ON_LOOT_STATE_CHANGE           = 9,    // (event, go, state)
        GAMEOBJECT_EVENT_ON_GO_STATE_CHANGED            = 10,   // (event, go, state)
        // UNUSED                                       = 11,   // (event, gameobject)
        GAMEOBJECT_EVENT_ON_ADD                         = 12,   // (event, gameobject)
        GAMEOBJECT_EVENT_ON_REMOVE                      = 13,   // (event, gameobject)
        GAMEOBJECT_EVENT_ON_USE                         = 14,   // (event, go, player) - Can return true to stop normal action
        GAMEOBJECT_EVENT_COUNT
    };

## Synopsis

`cancel = RegisterGameObjectEvent( entry, event, function )`

`cancel = RegisterGameObjectEvent( entry, event, function, shots )`

## Arguments

`number entry`

  GameObject entry Id.

  Valid numbers: integers from 0 to 4,294,967,295.

`number event`

  GameObject event Id, refer to GameObjectEvents above.

  Valid numbers: integers from 0 to 4,294,967,295.

`function function`

  Function to register.

`number shots (0)`

  The number of times the function will be called, 0 means "always call this function".

  Valid numbers: integers from 0 to 4,294,967,295.

## Returns

`function cancel`

  A function that cancels the binding when called.

# Keyboard shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result

# Search tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct` (or `str`), `enum`, `trait`, `typedef` (or `tdef`).

Generated on
© 2010 - 2024 Eluna Lua Engine