I did not try this but for anyone wanting to give it a try here is some example code how it could work (similar like Antisenil explained I yesterday just pseudo coded this with saving the role as someone enters a group and checking on that saved role as someone changes the role).
It's saved by charactername but maybe displayname works too if the OnGroupMemberLeft event's param characterName is actually the displayName (haven't tested this as I said)
And: If you change the zone or have a loading screen/reloadui the saved roles are gone, so one needs to add them to SavedVariables if they need to persists a reloadui!!!
Function OnGroupMemberJoined needs some love about finding the characterName of the groupMember who joined.
The part with the 0 to GetGroupSize() and find the unitTag by the index, could need a change.
Code:
local groupMemberRoles = {}
local function OnGroupMemberJoined(eventId, memberCharacterName, memberDisplayName, isLocalPlayer)
--GetUnitDisplayName()
for i=0, GetGroupSize(), 1 do
local groupMemberTag = GetGroupUnitTagByIndex(memberJoinedIndex)
if groupMemberTag ~= nil and ZO_Group_IsGroupUnitTag(groupMemberTag) and memberCharacterName == GetUnitName(groupMemberTag) then
local currentRole = GetGroupMemberRoles(groupMemberTag)
groupMemberRoles[memberCharacterName] = currentRole
return
end
end
end
EVENT_MANAGER:RegisterForEvent(addonName .. "_EVENT_GROUP_MEMBER_JOINED", EVENT_GROUP_MEMBER_JOINED, OnGroupMemberJoined)
local function OnGroupMemberLeft(eventCode, characterName, reason, wasLocalPlayer, amLeader)
if characterName ~= nil then groupMemberRoles[characterName] = nil end
end
EVENT_MANAGER:RegisterForEvent(addonName .. "_EVENT_GROUP_MEMBER_LEFT", EVENT_GROUP_MEMBER_LEFT, OnGroupMemberLeft)
local function OnGroupMemberRoleChanged(eventCode, groupMemberTag)
if ZO_Group_IsGroupUnitTag(groupMemberTag) then
--local memberDisplayName = GetUnitDisplayName(groupMemberTag)
local memberCharacterName = GetUnitName(groupMemberTag)
local lastRole = groupMemberRoles[memberDisplayName]
if lastRole ~= nil then
local currentRole = GetGroupMemberRoles(groupMemberTag)
if lastRole ~= currentRole then
d("[ROLE CHANGE ALERT]Account \'".. tostring(memberDisplayName) .. "\' changed role to: " .. currentRole .. " - (last role: ".. tostring(lastRole) ..")")
end
end
end
end
EVENT_MANAGER:RegisterForEvent(addonName .. "_EVENT_GROUP_MEMBER_ROLE_CHANGED", EVENT_GROUP_MEMBER_ROLE_CHANGED, OnGroupMemberRoleChanged)