View Single Post
09-06-23, 03:52 PM   #9
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Thank You so much it is working now

https://imgbox.com/8mv1MGox

wont let me add a pic so this is what i did

and for those wondering how i got it done here is the code...

Stats Code
Lua Code:
  1. -----------------
  2.     -- Stats
  3.     -----------------
  4.     if db.stats then
  5.  
  6.         local statsPlugin = CreateFrame('Frame', nil, Datapanel)
  7.         statsPlugin:RegisterEvent("PLAYER_ENTERING_WORLD")
  8.         statsPlugin:SetFrameStrata("BACKGROUND")
  9.         statsPlugin:SetFrameLevel(3)
  10.         statsPlugin:EnableMouse(true)
  11.  
  12.         local Text = statsPlugin:CreateFontString(nil, "OVERLAY")
  13.         Text:SetFont(db.font, db.fontSize,'THINOUTLINE')
  14.         PlacePlugin(db.stats, Text)
  15.  
  16.         local function ShowTooltip(self)
  17.             local playerRole, specIndex, ClassByID
  18.             local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  19.             GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  20.             GameTooltip:ClearLines()
  21.             GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Statistics")
  22.             GameTooltip:AddLine' '
  23.             if playerStat == 1 then
  24.                 local Total_Dodge = GetDodgeChance()
  25.                 local Total_Parry = GetParryChance()
  26.                 local Total_Block = GetBlockChance()
  27.                
  28.                 GameTooltip:AddLine(STAT_CATEGORY_DEFENSE)
  29.                 GameTooltip:AddDoubleLine(DODGE_CHANCE, format("%.2f%%", Total_Dodge),1,1,1)
  30.                 GameTooltip:AddDoubleLine(PARRY_CHANCE, format("%.2f%%", Total_Parry),1,1,1)
  31.                 GameTooltip:AddDoubleLine(BLOCK_CHANCE, format("%.2f%%", Total_Block),1,1,1)               
  32.                
  33.             elseif playerStat == 4 then
  34.                 local SC = GetSpellCritChance("2")
  35.                 local Total_Spell_Haste = UnitSpellHaste("player")
  36.                 local base, casting = GetManaRegen()
  37.                 local manaRegenString = "%d / %d"              
  38.                
  39.                 GameTooltip:AddLine(STAT_CATEGORY_SPELL)
  40.                 GameTooltip:AddDoubleLine(STAT_CRITICAL_STRIKE, format("%.2f%%", SC), 1, 1, 1)
  41.                 GameTooltip:AddDoubleLine(STAT_HASTE, format("%.2f%%", Total_Spell_Haste), 1, 1, 1)    
  42.                 GameTooltip:AddDoubleLine(MANA_REGEN, format(manaRegenString, base * 5, casting * 5), 1, 1, 1)
  43.  
  44.             elseif playerStat == 2 then        
  45.                 if playerClass == 253 then
  46.                     local Total_Range_Haste = GetRangedHaste("player")
  47.                     local Range_Crit = GetRangedCritChance("25")
  48.                     local speed = UnitRangedDamage("player")
  49.                     local Total_Range_Speed = speed
  50.                     local Melee_Crit = GetCritChance("player")
  51.                     local Total_Melee_Haste = GetMeleeHaste("player")
  52.                     local mainSpeed = UnitAttackSpeed("player");
  53.                     local MH = mainSpeed
  54.                    
  55.                     GameTooltip:AddLine(STAT_CATEGORY_MELEE)
  56.                     GameTooltip:AddDoubleLine(STAT_CRITICAL_STRIKE, format("%.2f%%", Melee_Crit), 1, 1, 1)     
  57.                     GameTooltip:AddDoubleLine(STAT_HASTE, format("%.2f%%", Total_Melee_Haste), 1, 1, 1)
  58.                     GameTooltip:AddDoubleLine(STAT_ATTACK_SPEED, format("%.2f".." (sec)", MH), 1, 1, 1)                
  59.                     GameTooltip:AddLine' '
  60.                     GameTooltip:AddLine(STAT_CATEGORY_RANGED)                  
  61.                     GameTooltip:AddDoubleLine(STAT_CRITICAL_STRIKE, format("%.2f%%", Range_Crit), 1, 1, 1) 
  62.                     GameTooltip:AddDoubleLine(STAT_HASTE, format("%.2f%%", Total_Range_Haste), 1, 1, 1)
  63.                     GameTooltip:AddDoubleLine(STAT_ATTACK_SPEED, format("%.2f".." (sec)", Total_Range_Speed), 1, 1, 1)                 
  64.                 else
  65.                     local Melee_Crit = GetCritChance("player")
  66.                     local Total_Melee_Haste = GetMeleeHaste("player")
  67.                     local mainSpeed = UnitAttackSpeed("player");
  68.                     local MH = mainSpeed
  69.                    
  70.                     GameTooltip:AddLine(STAT_CATEGORY_MELEE)
  71.                     GameTooltip:AddDoubleLine(STAT_CRITICAL_STRIKE, format("%.2f%%", Melee_Crit), 1, 1, 1)     
  72.                     GameTooltip:AddDoubleLine(STAT_HASTE, format("%.2f%%", Total_Melee_Haste), 1, 1, 1)
  73.                     GameTooltip:AddDoubleLine(STAT_ATTACK_SPEED, format("%.2f".." (sec)", MH), 1, 1, 1)
  74.                 end
  75.             end
  76.                
  77.             --GameTooltip:AddLine' '
  78.             --GameTooltip:AddLine(STAT_CATEGORY_GENERAL)           
  79.  
  80.  
  81.             GameTooltip:AddLine' '      
  82.             GameTooltip:AddLine("|cffeda55fClick|r to Open Charater Frame")
  83.             GameTooltip:Show()
  84.         end
  85.  
  86.         local function UpdateTank(self)
  87.             local armorString = hexa..ARMOR..hexb..": "
  88.             local displayNumberString = string.join("", "%s", "%d|r");
  89.             local base, effectiveArmor, armor, posBuff, negBuff = UnitArmor("player");
  90.             local Melee_Reduction = effectiveArmor
  91.            
  92.             Text:SetFormattedText(displayNumberString, armorString, effectiveArmor)
  93.             --Setup Tooltip
  94.             self:SetAllPoints(Text)
  95.         end
  96.  
  97.         local function UpdateCaster(self)
  98.             local spellpwr = GetSpellBonusDamage("2");
  99.             local displayNumberString = string.join("", "%s", "%d|r");
  100.            
  101.             Text:SetFormattedText(displayNumberString, hexa.."SP: "..hexb, spellpwr)
  102.            
  103.             --Setup Tooltip
  104.             self:SetAllPoints(Text)
  105.         end
  106.  
  107.         local function UpdateDamager(self) 
  108.             local displayNumberString = string.join("", "%s", "%d|r");
  109.                
  110.             if playerClass == 253 then
  111.                 local base, posBuff, negBuff = UnitRangedAttackPower("player")
  112.                 local Range_AP = base + posBuff + negBuff  
  113.                 pwr = Range_AP
  114.             else
  115.                 local base, posBuff, negBuff = UnitAttackPower("player")
  116.                 local Melee_AP = base + posBuff + negBuff      
  117.                 pwr = Melee_AP
  118.             end
  119.            
  120.             Text:SetFormattedText(displayNumberString, hexa.."AP: "..hexb, pwr)      
  121.             --Setup Tooltip
  122.             self:SetAllPoints(Text)
  123.         end
  124.  
  125.         local int = 5  
  126.         local function Update(self, t)
  127.             int = int - t
  128.             if int > 0 then return end
  129.             if playerRole == nil then
  130.                 Text:SetText(hexa.."No Stats"..hexb)
  131.             else
  132.                 if playerRole == "TANK" then
  133.                     UpdateTank(self)
  134.                 elseif playerRole == "HEALER" then
  135.                     UpdateCaster(self)
  136.                 elseif playerRole == "DAMAGER" then
  137.                     UpdateDamager(self)
  138.                 end
  139.             end
  140.             int = 2
  141.         end
  142.  
  143.         local function OnEvent(self, event, ...)
  144.             if event == 'PLAYER_ENTERING_WORLD' then
  145.                 self:UnregisterEvent('PLAYER_ENTERING_WORLD')
  146.             end
  147.            
  148.             if not playerRole then
  149.                 specIndex = GetSpecialization()
  150.                 playerRole = select(6, GetSpecializationInfo(specIndex))
  151.                 playerStat = select(7, GetSpecializationInfo(specIndex))
  152.                 playerClass = select(1, GetSpecializationInfo(specIndex))
  153.                 --print("playerRole", playerRole, specIndex) -- What did we get?
  154.                 --print("playerStat", playerStat, specIndex) -- What did we get?
  155.                 print("playerClass", playerClass, specIndex) -- What did we get?
  156.             end  
  157.  
  158.             -- update datatext
  159.             if event ~= 'PLAYER_ENTERING_WORLD' then
  160.                 self:SetScript('OnUpdate', Update)
  161.             end
  162.         end
  163.  
  164.         statsPlugin:SetScript("OnEnter", function() ShowTooltip(statsPlugin) end)
  165.         statsPlugin:SetScript("OnLeave", function() GameTooltip:Hide() end)
  166.         statsPlugin:SetScript('OnEvent', OnEvent)
  167.         statsPlugin:SetScript("OnUpdate", Update)
  168.        
  169.         statsPlugin:SetScript("OnMouseDown", function() ToggleCharacter("PaperDollFrame") end)
  170.         --Update(statsPlugin, 10)
  171.     end

Spec Code:
Lua Code:
  1. -----------------
  2.     -- Spec
  3.     -----------------
  4.  
  5.     if db.spec then
  6.  
  7.         local specPlugin = CreateFrame('Frame', nil, Datapanel)
  8.         specPlugin:EnableMouse(true)
  9.         specPlugin:SetFrameStrata('BACKGROUND')
  10.         specPlugin:SetFrameLevel(3)
  11.  
  12.         local Text = specPlugin:CreateFontString(nil, 'OVERLAY')
  13.         Text:SetFont(db.font, db.fontSize,'THINOUTLINE')
  14.         PlacePlugin(db.spec, Text)
  15.  
  16.         local talent = {}
  17.         local active
  18.         local talentString = string.join('', '|cffFFFFFF%s|r ')
  19.         local activeString = string.join('', '|cff00FF00' , ACTIVE_PETS, '|r')
  20.         local inactiveString = string.join('', '|cffFF0000', FACTION_INACTIVE, '|r')
  21.         local playerRole, specIndex
  22.  
  23.         local int = 5
  24.         local function Update(self, t)
  25.            
  26.             int = int - t
  27.             if int > 0 then return end
  28.             --active = GetActiveSpecGroup(false, false)
  29.             if playerClass ~= nil then
  30.                 Text:SetFormattedText(talentString, hexa..select(2, GetSpecializationInfo(GetSpecialization()))..hexb)
  31.             else
  32.                 Text:SetText(hexa.."No Spec"..hexb)
  33.             end
  34.             int = 2
  35.            
  36.         end
  37.  
  38.  
  39.         specPlugin:SetScript('OnEnter', function(self)
  40.             local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  41.             GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  42.  
  43.             GameTooltip:ClearLines()
  44.             GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Spec")
  45.             GameTooltip:AddLine' '
  46.             if playerClass ~= nil then
  47.                 for i = 1, GetActiveSpecGroup() do
  48.                     if GetSpecialization(false, false, i) then
  49.                         GameTooltip:AddLine(string.join('- ', string.format(talentString, select(2, GetSpecializationInfo(GetSpecialization())))))
  50.                     end
  51.                 end
  52.             else
  53.                 GameTooltip:AddLine("You have not chosen a Spec yet.")
  54.             end
  55.             GameTooltip:AddLine' '      
  56.             GameTooltip:AddLine("|cffeda55fClick|r to Open Talent Tree")
  57.             GameTooltip:Show()
  58.         end)
  59.  
  60.         specPlugin:SetScript('OnLeave', function() GameTooltip:Hide() end)
  61.  
  62.         local function OnEvent(self, event, ...)
  63.             if event == 'PLAYER_ENTERING_WORLD' then
  64.                 self:UnregisterEvent('PLAYER_ENTERING_WORLD')
  65.             end
  66.      
  67.             -- Setup Talents Tooltip
  68.             self:SetAllPoints(Text)
  69.             if not playerRole then
  70.                 specIndex = GetSpecialization()
  71.                 playerClass = select(2, GetSpecializationInfo(specIndex))
  72.                 --print("playerClass", playerClass, specIndex) -- What did we get?
  73.             end
  74.             -- update datatext
  75.             if event ~= 'PLAYER_ENTERING_WORLD' then
  76.                 self:SetScript('OnUpdate', Update)
  77.             end
  78.         end
  79.  
  80.  
  81.  
  82.         specPlugin:RegisterEvent('PLAYER_ENTERING_WORLD');
  83.         specPlugin:RegisterEvent('CHARACTER_POINTS_CHANGED');
  84.         specPlugin:RegisterEvent('PLAYER_TALENT_UPDATE');
  85.         specPlugin:RegisterEvent('ACTIVE_TALENT_GROUP_CHANGED')
  86.         specPlugin:RegisterEvent("EQUIPMENT_SETS_CHANGED")
  87.         specPlugin:SetScript('OnEvent', OnEvent)
  88.         specPlugin:SetScript('OnUpdate', Update)
  89.  
  90.         specPlugin:SetScript("OnMouseDown", function() ToggleTalentFrame() end)
  91.     end

Last edited by cokedrivers : 09-06-23 at 08:04 PM.
  Reply With Quote