Method Global:RegisterPlayerEvent [-] [+]
Registers a Player event handler.
enum PlayerEvents
{
PLAYER_EVENT_ON_CHARACTER_CREATE = 1, // (event, player)
PLAYER_EVENT_ON_CHARACTER_DELETE = 2, // (event, guid)
PLAYER_EVENT_ON_LOGIN = 3, // (event, player)
PLAYER_EVENT_ON_LOGOUT = 4, // (event, player)
PLAYER_EVENT_ON_SPELL_CAST = 5, // (event, player, spell, skipCheck)
PLAYER_EVENT_ON_KILL_PLAYER = 6, // (event, killer, killed)
PLAYER_EVENT_ON_KILL_CREATURE = 7, // (event, killer, killed)
PLAYER_EVENT_ON_KILLED_BY_CREATURE = 8, // (event, killer, killed)
PLAYER_EVENT_ON_DUEL_REQUEST = 9, // (event, target, challenger)
PLAYER_EVENT_ON_DUEL_START = 10, // (event, player1, player2)
PLAYER_EVENT_ON_DUEL_END = 11, // (event, winner, loser, type)
PLAYER_EVENT_ON_GIVE_XP = 12, // (event, player, amount, victim) - Can return new XP amount
PLAYER_EVENT_ON_LEVEL_CHANGE = 13, // (event, player, oldLevel)
PLAYER_EVENT_ON_MONEY_CHANGE = 14, // (event, player, amount) - Can return new money amount
PLAYER_EVENT_ON_REPUTATION_CHANGE = 15, // (event, player, factionId, standing, incremental) - Can return new standing
PLAYER_EVENT_ON_TALENTS_CHANGE = 16, // (event, player, points)
PLAYER_EVENT_ON_TALENTS_RESET = 17, // (event, player, noCost)
PLAYER_EVENT_ON_CHAT = 18, // (event, player, msg, Type, lang) - Can return false, newMessage
PLAYER_EVENT_ON_WHISPER = 19, // (event, player, msg, Type, lang, receiver) - Can return false, newMessage
PLAYER_EVENT_ON_GROUP_CHAT = 20, // (event, player, msg, Type, lang, group) - Can return false, newMessage
PLAYER_EVENT_ON_GUILD_CHAT = 21, // (event, player, msg, Type, lang, guild) - Can return false, newMessage
PLAYER_EVENT_ON_CHANNEL_CHAT = 22, // (event, player, msg, Type, lang, channel) - Can return false, newMessage
PLAYER_EVENT_ON_EMOTE = 23, // (event, player, emote) - Not triggered on any known emote
PLAYER_EVENT_ON_TEXT_EMOTE = 24, // (event, player, textEmote, emoteNum, guid)
PLAYER_EVENT_ON_SAVE = 25, // (event, player)
PLAYER_EVENT_ON_BIND_TO_INSTANCE = 26, // (event, player, difficulty, mapid, permanent)
PLAYER_EVENT_ON_UPDATE_ZONE = 27, // (event, player, newZone, newArea)
PLAYER_EVENT_ON_MAP_CHANGE = 28, // (event, player)
// Custom
PLAYER_EVENT_ON_EQUIP = 29, // (event, player, item, bag, slot)
PLAYER_EVENT_ON_FIRST_LOGIN = 30, // (event, player)
PLAYER_EVENT_ON_CAN_USE_ITEM = 31, // (event, player, item) - Can return InventoryResult enum value
PLAYER_EVENT_ON_LOOT_ITEM = 32, // (event, player, item, count, lootGuid, lootObj)
PLAYER_EVENT_ON_ENTER_COMBAT = 33, // (event, player, enemy)
PLAYER_EVENT_ON_LEAVE_COMBAT = 34, // (event, player)
PLAYER_EVENT_ON_REPOP = 35, // (event, player)
PLAYER_EVENT_ON_RESURRECT = 36, // (event, player)
PLAYER_EVENT_ON_LOOT_MONEY = 37, // (event, player, amount)
PLAYER_EVENT_ON_QUEST_ABANDON = 38, // (event, player, questId)
PLAYER_EVENT_ON_LEARN_TALENTS = 39, // (event, player, talentId, talentRank, spellid)
PLAYER_EVENT_ON_ENVIRONMENTAL_DEATH = 40, // (event, player, environmentalDamageType)
PLAYER_EVENT_ON_TRADE_ACCEPT = 41, // (event, player, target) - Can return false to interrupt trade
PLAYER_EVENT_ON_COMMAND = 42, // (event, player, command) - player is nil if command used from console. Can return false
PLAYER_EVENT_ON_SKILL_CHANGE = 43, // (event, player, skillId, skillValue) - Returns new skill level value
PLAYER_EVENT_ON_LEARN_SPELL = 44, // (event, player, spellId)
PLAYER_EVENT_ON_ACHIEVEMENT_COMPLETE = 45, // (event, player, achievementId)
PLAYER_EVENT_ON_DISCOVER_AREA = 46, // (event, player, area)
PLAYER_EVENT_ON_UPDATE_AREA = 47, // (event, player, oldArea, newArea)
PLAYER_EVENT_ON_TRADE_INIT = 48, // (event, player, target) - Can return false to interrupt trade
PLAYER_EVENT_ON_SEND_MAIL = 49, // (event, player, recipientGuid) - Can return false to interrupt sending
PLAYER_EVENT_ON_DAMAGE_DEALT = 50, // (event, player, target, damage, damageSchoolMask, spellInfo) - Can return new damage amount
// UNUSED = 51, // (event, player)
// UNUSED = 52, // (event, player)
// UNUSED = 53, // (event, player)
PLAYER_EVENT_ON_QUEST_STATUS_CHANGED = 54, // (event, player, questId, status)
PLAYER_EVENT_ON_ITEM_DESTROYED = 55, // (event, player, item, count) - Can return InventoryResult != EQUIP_ERR_OK to prevent item destruction
PLAYER_EVENT_ON_CAN_ATTACK = 56, // (event, player, target) - Can return false to interrupt attack
PLAYER_EVENT_ON_QUEST_CREDIT = 57, // (event, player, questId, creatureOrGameObjectId)
PLAYER_EVENT_ON_DAMAGE_TAKEN = 58, // (event, player, attacker, damage, damageSchoolMask, spellInfo) - Can return new damage
PLAYER_EVENT_ON_UNEQUIP = 59, // (event, player, item, bag, slot)
PLAYER_EVENT_ON_UNLEARN_SPELL = 60, // (event, player, spellId)
PLAYER_EVENT_ON_PERSONAL_BANK_ITEM_MOVE = 61, // (event, player, item, srcBank, srcContainer, srcSlotId, destItem, destBank, destContainer, destSlotId, splitedAmount) - Can return 0 to stop move, 1 to allow move, 2 to allow move and delete source item, 3 to allow move and stack items, > 3 to allow move and change item entry after move
PLAYER_EVENT_ON_QUEST_ACCEPT = 62, // (event, player, questId) - Can return false to interrupt quest accept
PLAYER_EVENT_ON_BUY_ITEM = 63, // (event, player, creature, itemId, count) - Can return false to prevent buying item
PLAYER_EVENT_ON_SELL_ITEM = 64, // (event, player, creature, itemId, count, sellPrice) - Can return false to prevent selling item, return sellPrice
PLAYER_EVENT_ON_ELUNA_RELOAD = 65, // (event, player)
PLAYER_EVENT_ON_SET_AMMO = 66, // (event, player, itemId) - Can return false to prevent setting ammo item
PLAYER_EVENT_ON_PVP_COMBAT = 67, // (event, player, enemy)
PLAYER_EVENT_ON_LOGOUT_REQUEST = 68, // (event, player) - Can return false to prevent logout request
PLAYER_EVENT_ON_PERSONAL_BANK_OPEN = 69, // (event, player) - Can return false to prevent opening personal bank
PLAYER_EVENT_ON_CAN_BANK_ITEM = 70, // (event, player, item) - Can return false to prevent item move
PLAYER_EVENT_ON_BANK_ITEM_MOVE = 71, // (event, player, item, srcBank, srcContainer, srcSlotId, destItem, destBank, destContainer, destSlotId, splitedAmount) - Can return false
PLAYER_EVENT_ON_INSTANCE_RESET = 72, // (event, player, instanceId)
PLAYER_EVENT_ON_POWER_ZERO = 73, // (event, player, powerType)
PLAYER_EVENT_ON_GRID_RELOCATION = 74, // (event, player, x, y)
PLAYER_EVENT_ON_CAN_SEE = 75, // (event, player, target) - Can return false to make creature invisible
PLAYER_EVENT_ON_TRADE_SET_ITEM = 76, // (event, player, target, item) - Can return false to interrupt trade
PLAYER_EVENT_ON_TRADE_SET_MONEY = 77, // (event, player, target, money) - Can return false to interrupt trade
};
Synopsis
cancel = RegisterPlayerEvent( event, function )
cancel = RegisterPlayerEvent( event, function, shots )
Arguments
number eventPlayer event Id, refer to PlayerEvents above.
Valid numbers: integers from 0 to 4,294,967,295.
function functionFunction 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 cancelA function that cancels the binding when called.