View Single Post
04/09/14, 06:09 AM   #2
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
You have

EVENT_EXPERIENCE_GAIN (integer value, integer reason)
EVENT_EXPERIENCE_GAIN_DISCOVERY (string areaName, integer value)
EVENT_EXPERIENCE_UPDATE (string unitTag, integer currentExp, integer maxExp, integer reason)

The Update one occurs when someone levels in your vicinity.

The calling function you are using right but the function being used isn't being utilised properly.

Lua Code:
  1. local function UpdateXP(eventID,value,reason)
  2.      CHAT_SYSTEM:AddMessage(string.format("You have gained %d experience.",value))
  3. end
  4.  
  5. local function UpdateXPDiscovery(eventID,areaName,value)
  6.     CHAT_SYSTEM:AddMessage(string.format("You have gained %d experience through discovering %s",value,areaName))
  7. end
  8.  
  9. EVENT_MANAGER:RegisterForEvent("Mahalia", EVENT_EXPERIENCE_GAIN, UpdateXP)
  10. EVENT_MANAGER:RegisterForEvent("Mahalia", EVENT_EXPERIENCE_GAIN_DISCOVERY, UpdateXPDiscovery)

As you can see the eventID is needed in the function you use to process the event. Some events are still to have their parameters discovered but they always have the eventID as their first parameter.

I also notice that you had it as GAINED rather than GAIN. Quite understandable.
  Reply With Quote