View Single Post
03/19/23, 01:12 PM   #12
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,000
Event register and unregister always is 1 event only, not multiple within one call.

And the event filters should work like I had added my code above, with the first para = the same unique name you have used to register your event with.
You can register multiple filters with the same unique name, as long as the filtertype is different (e.g. REGISTER_FILTER_POWER_TYPE and REGISTER_FILTER_UNIT_TAG works, but 2x REGISTER_FILTER_UNIT_TAG won't work with the same unique name).

Example:
Code:
EVENT_MANAGER:RegisterForEvent("ZO_HealthWarning", EVENT_POWER_UPDATE, OnPowerUpdate)
EVENT_MANAGER:AddFilterForEvent("ZO_HealthWarning", EVENT_POWER_UPDATE, REGISTER_FILTER_POWER_TYPE, COMBAT_MECHANIC_FLAGS_HEALTH)
EVENT_MANAGER:AddFilterForEvent("ZO_HealthWarning", EVENT_POWER_UPDATE, REGISTER_FILTER_UNIT_TAG, "player")
If your code works though it is ignoring the filter then and this is why "it works" ? You can check if your function EVENT_GROUP_MEMBER_ROLE_CHANGED is fired for any other group member than yourself, by adding a d("debug message here") in your callback function
e.g. d(">unitTag: " ..tostring(unitTag))

Perhas the group related event filters only accept unitTags that start with group. e.g. the unitTag start at group1 and count up to groupn. Maybe "player" is never send to the event EVENT_GROUP_MEMBER_ROLE_CHANGED then?
You can remove the filter and test what the unitTag is like as you yourself change the role (via the d debug message).
Maybe it will be group2 or similar then and that's why it won't work with "player". In this case leave the event filter away and check manuallyif the group unitTag passed to the callback function parameter is the one of yourself.

You should be able to detect that via GetUnitDisplayName(unitTag) and comparing the displayName with GetDisplayName() result (cache that once at the start of your addon as it would not change in between during gameplay).

Last edited by Baertram : 03/19/23 at 01:18 PM.
  Reply With Quote