Thread Tools Display Modes
Prev Previous Post   Next Post Next
11-18-18, 09:24 AM   #1
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Help with checking a Players Role

So im trying to get the players role with the following code:

Code:
local isCaster = {
	-- All Classes are needed as to not cause a error when the table is called.
	-- SpecID - Spec - Role
	DEATHKNIGHT = {
		nil, -- 250 - Blood - (TANK) 
		nil, -- 251 - Frost - (MELEE_DPS)
		nil, -- 252 - Unholy - (MELEE_DPS)
	},
	DEMONHUNTER = {
		nil, -- 577 - Havoc - (TANK)
		nil, -- 581 - Vengeance - (MELEE_DPS)
	},
	DRUID = { 
		true, -- 102 - Balance - (CASTER_DPS)
		nil,  -- 103 - Feral - (MELEE_DPS)
		nil,  -- 104 Guardian - (TANK)
		nil,  -- 105 Restoration - (HEALER)
	},
	HUNTER = {
		nil, -- 253 - Beast Mastery - (RANGED_DPS)
		nil, -- 254 - Marksmanship - (RANGED_DPS)
		nil, -- 255 - Survival - (RANGED_DPS)
	},
	MAGE = { 
		true, -- 62 - Arcane - (CASTER_DPS)
		true, -- 63 - Fire - (CASTER_DPS)
		true, -- 64 - Frost - (CASTER_DPS)
	}, 
	MONK = {
		nil, -- 268 - Brewmaster - (TANK)
		nil, -- 269 - Windwalker - (MELEE_DPS)
		nil, -- 270 - Mistweaver - (HEALER)
	}, 
	PALADIN = {
		nil, -- 65 - Holy - (HEALER)
		nil, -- 66 - Protection - (TANK)
		nil, -- 70 - Retribution - (MELEE_DPS)
	},
	PRIEST = { 
		nil,  -- 256 - Discipline - (HEALER}
		nil,  -- 257 - Holy - (HEALER)
		true, -- 258 - Shadow - (CASTER_DPS)
	},
	ROGUE = {
		nil, -- 259 - Assassination - (MELEE_DPS)
		nil, -- 260 - Combat - (MELEE_DPS)
		nil, -- 261 - Subtlety - (MELEE_DPS)
	}, 
	SHAMAN = { 
		true, -- 262 - Elemental - (CASTER_DPS)
		nil,  -- 263 - Enhancement - (MELEE_DPS)
		nil,  -- 264 - Restoration - (HEALER)
	},
	WARLOCK = { 
		true, -- 265 - Affliction - (CASTER_DPS)
		true, -- 266 - Demonology - (CASTER_DPS)
		true, -- 267 - Destruction - (CASTER_DPS)
	}, 
	WARRIOR = {
		nil, -- 71 - Arms - (MELEE_DPS)
		nil, -- 72 - Furry - (MELEE_DPS)
		nil, -- 73 - Protection - (TANK)
	},
}


local spec = GetSpecialization()
if not spec then
	playerRole = nil
	return
end

local specRole = GetSpecializationRole(spec)
if specRole == "DAMAGER" then
	if isCaster[class][spec] then
		playerRole = "CASTER"
		return
	end
end

local playerRole = specRole
but it is not pulling any info when i us it in one of my stats like:
Code:
	local function Update(self, t)
		
		int = int - t
		if int > 0 then return end
		active = GetActiveSpecGroup(false, false)
		if playerRole~= nil then
			Text:SetFormattedText(talentString, hexa..select(2, GetSpecializationInfo(GetSpecialization(false, false, active)))..hexb)
		else
			Text:SetText(hexa.."No Spec"..hexb)
		end
		int = 2

		-- disable script	
		--self:SetScript('OnUpdate', nil)
		
	end
can anyone help out with this.

Now i do get it to wrok if i use Ace3 Libs but Im trying to get my addon as slim as possible.

Thanks in Advance
Coke
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Help with checking a Players Role


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off