View Single Post
02-05-22, 01:58 AM   #2
joejoe317
A Defias Bandit
Join Date: Feb 2022
Posts: 2
I figured out the part for when I select a role, now I need to figure out how to change when someone else selects a role... I would assume this part would function the same when someone enters or leaves an arena.

For reference:

Code:
local NewName = UnitClass("player");
local frame_handlers = {}

local function EventHandler(self, event, ...)
    if event == 'LFG_ROLE_CHECK_ROLE_CHOSEN' then
        -- alter stuff
		local player, isTank, isHealer, isDamage = ...;

		--Yes, consecutive string concatenation == bad for garbage collection. But the alternative is either extremely unslightly or localization unfriendly. (Also, this happens fairly rarely)
		local roleList;

		if ( isTank ) then
			roleList = INLINE_TANK_ICON.." "..TANK;
		end
		if ( isHealer ) then
			if ( roleList ) then
				roleList = roleList..PLAYER_LIST_DELIMITER.." "..INLINE_HEALER_ICON.." "..HEALER;
			else
				roleList = INLINE_HEALER_ICON.." "..HEALER;
			end
		end
		if ( isDamage ) then
			if ( roleList ) then
				roleList = roleList..PLAYER_LIST_DELIMITER.." "..INLINE_DAMAGER_ICON.." "..DAMAGER;
			else
				roleList = INLINE_DAMAGER_ICON.." "..DAMAGER;
			end
		end
		assert(roleList);
		ChatFrame_DisplaySystemMessageInPrimary(string.format(LFG_ROLE_CHECK_ROLE_CHOSEN, NewName, roleList));
		return NewName, isTank, isHealer, isDamage
    end
    frame_handlers[self](self, event, ...)
end

local function HookFrames(...)
    for i = 1 ,select('#', ...) do
        local frame = select(i, ...)
        if not frame_handlers[frame] and frame:GetScript('OnEvent') then
            frame_handlers[frame] = frame:GetScript('OnEvent')
            frame:SetScript('OnEvent', EventHandler)
        end
    end
end
  Reply With Quote