Thread Tools Display Modes
Prev Previous Post   Next Post Next
04-06-20, 03:27 AM   #1
Lybrial
A Flamescale Wyrmkin
AddOn Compiler - Click to view compilations
Join Date: Jan 2010
Posts: 120
Russians in Battlegrounds?!

Hi,

im currently working on my nameplates and so I want to give some additional informations
on my nameplates when im in a battleground.

Im showing the class spec of enemies.

So at first im gathering class informations:

Lua Code:
  1. VALUES.Classes = {}
  2.  
  3. for classID = 1, MAX_CLASSES do
  4.     local _, class = GetClassInfo(classID);
  5.  
  6.     VALUES.Classes[class] = {}
  7.  
  8.     for i = 1, GetNumSpecializationsForClassID(classID) do
  9.         local specID, specName, _, iconID, role = GetSpecializationInfoForClassID(classID, i);
  10.  
  11.         VALUES.Classes[class][specName] = {
  12.             specID = specID,
  13.             role = role,
  14.             iconID = iconID,
  15.         }
  16.     end
  17. end

Second im building an array of current players in the battleground:

Lua Code:
  1. local players = {}
  2.  
  3. local function buildName(unit)
  4.     local name, realm = UNITS:UnitName(unit);
  5.  
  6.     -- UnitName realm: The realm the specified unit is from.
  7.     -- For "player" returns nil.
  8.     -- For any other character on your own realm returns an empty string.
  9.     -- This is as of 1.12.
  10.  
  11.     if (realm and (realm ~= "")) then
  12.         name = name .. "-" .. realm;
  13.     end
  14.  
  15.     return name;
  16. end
  17.  
  18. local function deleteSpecs()
  19.     TABLES:Wipe(players);
  20. end
  21.  
  22. local function updateSpecs()
  23.     local _, instanceType = GetInstanceInfo();
  24.  
  25.     if (instanceType == "pvp") then
  26.         for i = 1, GetNumBattlefieldScores() do
  27.             local name, _, _, _, _, _, _, _, class, _, _, _, _, _, _, specialization = GetBattlefieldScore(i);
  28.  
  29.             if (name and class and specialization) then
  30.                 players[name] = {
  31.                     class = class;
  32.                     specialization = specialization;
  33.                 }
  34.             end
  35.         end
  36.     elseif (instanceType == "arena") then
  37.         for i = 1, GetNumArenaOpponentSpecs() do
  38.             local name = buildName(STRINGS:Format("arena%d", i));
  39.  
  40.             if (name and (name ~= UNKNOWN)) then
  41.                 local specID = GetArenaOpponentSpec(i);
  42.                 local _, specialization, _, _, _, class = GetSpecializationInfoByID(specID);
  43.  
  44.                 if (class and specialization) then
  45.                     players[name] = {
  46.                         class = class;
  47.                         specialization = specialization;
  48.                     }
  49.                 end
  50.             end
  51.         end
  52.     end
  53. end
  54.  
  55. local frame = FRAMES:CreateFrame("Frame", nil, FRAMES.UIParent);
  56.  
  57. frame:SetScript("OnEvent", function(_, event)
  58.     if (event == "PLAYER_ENTERING_WORLD") then
  59.         deleteSpecs();
  60.         updateSpecs();
  61.     elseif ((event == "ARENA_OPPONENT_UPDATE") or (event == "UPDATE_BATTLEFIELD_SCORE")) then
  62.         updateSpecs();
  63.     end
  64. end);
  65. frame:RegisterEvent("UPDATE_BATTLEFIELD_SCORE");
  66. frame:RegisterEvent("ARENA_OPPONENT_UPDATE");
  67. frame:RegisterEvent("PLAYER_ENTERING_WORLD");

And on my nameplate update function im doing:

Lua Code:
  1. local function update(self)
  2.     local element = self.Specialization;
  3.  
  4.     if (element.PreUpdate) then
  5.         element:PreUpdate();
  6.     end
  7.  
  8.     local _, instanceType = GetInstanceInfo();
  9.  
  10.     if (instanceType == "pvp" or instanceType == "arena") then
  11.         local name = buildName(self.unit);
  12.  
  13.         if (players[name]) then
  14.             local class = players[name].class;
  15.             local specialization = players[name].specialization;
  16.  
  17.             element.Icon:SetTexture(VALUES.Classes[class][specialization].iconID);
  18.             element.Icon:SetTexCoord(0.1, 0.9, 0.1, 0.9);
  19.  
  20.             element:Show();
  21.         else
  22.             element:Hide();
  23.         end
  24.     end
  25.  
  26.     if (element.PostUpdate) then
  27.         return element:PostUpdate(self.unit);
  28.     end
  29. end

This works perfectly! For everybody except russian players. There are some rogue and demon hunter specs for which I get no results for. Is there anything special about some russian names, server names or spec names (except from the character set ofcourse)?

Last edited by Lybrial : 04-06-20 at 03:48 AM.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Russians in Battlegrounds?!


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