Interface:Creature Events - novasdream/forgottenserver GitHub Wiki

These events run whenever something happens to a creature and/or player. ###Available events: onAdvance()
onDeath()
onExtendedOpcode()
onHealthChange()
onKill()
onLogin()
onLogout()
onManaChange()
onModalWindow()
onPrepareDeath()
onTextEdit()
onThink()


###### onAdvance() > **Description:** N/A > **Parameters:** N/A > **Accepted return values:** N/A > **Example:** ```Lua N/A ``` Added in version: 1.0
###### onDeath() > **Description:** N/A > **Parameters:** N/A > **Accepted return values:** N/A > **Example:** ```Lua N/A ``` Added in version: 1.0
###### onExtendedOpcode() > **Description:** N/A > **Parameters:** N/A > **Accepted return values:** N/A > **Example:** ```Lua N/A ``` Added in version: 1.0
###### onHealthChange() > **Description:** This event runs each time a (registered) creatures health changes. > **Parameters:**
  • _creature_ - _Creature userdata of the victim_
  • _attacker_ - _Creature userdata of the attacker, can be nil_
  • _primaryDamage_ - _First part of the damage (always a positive value)_
  • _primaryType_ - _First damage type_
  • _secondaryDamage_ - _Second part of the damage (always a positive value)_
  • _secondaryType_ - _Second damage type_
  • _origin_ - _What were you hit by? A spell? Melee?_
> **Accepted return values:** 2 or more values must be returned otherwise the event will be cancelled. ```Lua return 5, COMBAT_FIREDAMAGE, 5, COMBAT_PHYSICALDAMAGE ``` > **Example:** ```Lua function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType) if not attacker then return 5, COMBAT_FIREDAMAGE, 0, COMBAT_NONE end return primaryDamage, primaryType, -secondaryDamage, secondaryType end ``` Added in version: 1.0
###### onKill() > **Description:** N/A > **Parameters:** N/A > **Accepted return values:** N/A > **Example:** ```Lua N/A ``` Added in version: 1.0
###### onLogin() > **Description:** N/A > **Parameters:** N/A > **Accepted return values:** N/A > **Example:** ```Lua N/A ``` Added in version: 1.0
###### onLogout() > **Description:** N/A > **Parameters:** N/A > **Accepted return values:** N/A > **Example:** ```Lua N/A ``` Added in version: 1.0
###### onManaChange() > **Description:** This event runs each time a (registered) creatures mana changes. > **Parameters:**
  • _creature_ - _Creature userdata of the victim_
  • _attacker_ - _Creature userdata of the attacker, can be nil_
  • _manaChange_ - _How much mana you have gained or lost (always a positive value)_
> **Accepted return values:** 1 value must be returned otherwise the event will be cancelled. ```Lua return 5 ``` > **Example:** ```Lua function onManaChange(creature, attacker, manaChange) if not attacker then return 0 end return manaChange end ``` Added in version: 1.0
###### onModalWindow() > **Description:** N/A > **Parameters:** N/A > **Accepted return values:** N/A > **Example:** ```Lua N/A ``` Added in version: 1.0
###### onPrepareDeath() > **Description:** N/A > **Parameters:** N/A > **Accepted return values:** N/A > **Example:** ```Lua N/A ``` Added in version: 1.0
###### onTextEdit() > **Description:** N/A > **Parameters:** N/A > **Accepted return values:** N/A > **Example:** ```Lua N/A ``` Added in version: 1.0
###### onThink() > **Description:** N/A > **Parameters:** N/A > **Accepted return values:** N/A > **Example:** ```Lua N/A ``` Added in version: 1.0
⚠️ **GitHub.com Fallback** ⚠️