alexdubovyck

[НЕ УДАЛЯТЬ!] https://www.youtube.com/watch?v=egVLiOOjYIA

Oct 25th, 2017
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.98 KB | None | 0 0
  1. ---------------------------------------------
  2. -- Показывает % проценты около фрейма игрока, его таргета и т д.
  3. ---------------------------------------------
  4. -- do
  5. local t_hpFrame = CreateFrame("Frame", "TargetPercent", TargetFrameHealthBar)
  6. t_hpFrame:SetPoint("LEFT", TargetFrameHealthBar, "LEFT", -46, 0)
  7. t_hpFrame:SetWidth(45)
  8. t_hpFrame:SetHeight(20)
  9. t_hpFrame.text = t_hpFrame:CreateFontString("TargetPercentText", "OVERLAY")
  10. t_hpFrame.text:SetAllPoints(t_hpFrame)
  11. t_hpFrame.text:SetFontObject(TextStatusBarText)
  12. t_hpFrame.text:SetJustifyH("RIGHT")
  13. t_hpFrame:RegisterEvent("PLAYER_TARGET_CHANGED")
  14. t_hpFrame:RegisterEvent("UNIT_HEALTH")
  15. t_hpFrame:SetScript("OnEvent", function(frame, _, unit)
  16. if unit and not UnitIsUnit(unit, "target") then return end
  17. local hp = UnitHealth("target")
  18. if hp > 0 then
  19. hp = hp / UnitHealthMax("target") * 100
  20. frame.text:SetFormattedText("%.1f%%", hp)
  21. else
  22. frame.text:SetText("0%")
  23. end
  24. end)
  25.  
  26. local f_hpFrame = CreateFrame("Frame", "FocusPercent", FocusFrameHealthBar)
  27. f_hpFrame:SetPoint("LEFT", FocusFrameHealthBar, "LEFT", -46, -20)
  28. f_hpFrame:SetWidth(45)
  29. f_hpFrame:SetHeight(20)
  30. f_hpFrame.text = f_hpFrame:CreateFontString("FocusPercentText", "OVERLAY")
  31. f_hpFrame.text:SetAllPoints(f_hpFrame)
  32. f_hpFrame.text:SetFontObject(TextStatusBarText)
  33. f_hpFrame.text:SetJustifyH("RIGHT")
  34. f_hpFrame:RegisterEvent("PLAYER_FOCUS_CHANGED")
  35. f_hpFrame:SetScript("OnShow", function() f_hpFrame:RegisterEvent("UNIT_HEALTH") end)
  36. f_hpFrame:SetScript("OnHide", function() f_hpFrame:UnregisterEvent("UNIT_HEALTH") end)
  37. f_hpFrame:SetScript("OnEvent", function(frame, _, unit)
  38. if unit and not UnitIsUnit(unit, "focus") then return end
  39. local hp = UnitHealth("focus")
  40. if hp > 0 then
  41. hp = hp / UnitHealthMax("focus") * 100
  42. frame.text:SetFormattedText("%.1f%%", hp)
  43. else
  44. frame.text:SetText("0%")
  45. end
  46. end)
  47.  
  48. local p_hpFrame = CreateFrame("Frame", "PlayerPercent", PlayerFrameHealthBar)
  49. p_hpFrame:SetPoint("RIGHT", PlayerFrameHealthBar, "RIGHT", 40, -20)
  50. p_hpFrame:SetWidth(45)
  51. p_hpFrame:SetHeight(20)
  52. p_hpFrame.text = p_hpFrame:CreateFontString("PlayerPercentText", "OVERLAY")
  53. p_hpFrame.text:SetAllPoints(p_hpFrame)
  54. p_hpFrame.text:SetFontObject(TextStatusBarText)
  55. p_hpFrame.text:SetJustifyH("RIGHT")
  56. p_hpFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
  57. p_hpFrame:RegisterEvent("UNIT_HEALTH")
  58. p_hpFrame:SetScript("OnShow", function() p_hpFrame:RegisterEvent("UNIT_HEALTH") end)
  59. p_hpFrame:SetScript("OnHide", function() p_hpFrame:UnregisterEvent("UNIT_HEALTH") end)
  60. p_hpFrame:SetScript("OnEvent", function(frame, _, unit)
  61. if unit and not UnitIsUnit(unit, "player") then return end
  62. local hp = UnitHealth("player")
  63. if hp > 0 then
  64. hp = hp / UnitHealthMax("player") * 100
  65. frame.text:SetFormattedText("%.1f%%", hp)
  66. else
  67. frame.text:SetText("0%")
  68. end
  69. end)
  70.  
  71. local partymf_hpFrame = CreateFrame("Frame", "PartyPercent", PartyMemberFrame1HealthBar)
  72. partymf_hpFrame:SetPoint("RIGHT", PartyMemberFrame1HealthBar, "RIGHT", 40, -28)
  73. partymf_hpFrame:SetWidth(45)
  74. partymf_hpFrame:SetHeight(20)
  75. partymf_hpFrame.text = partymf_hpFrame:CreateFontString("PartyPercentText", "OVERLAY")
  76. partymf_hpFrame.text:SetAllPoints(partymf_hpFrame)
  77. partymf_hpFrame.text:SetFontObject(TextStatusBarText)
  78. partymf_hpFrame.text:SetJustifyH("RIGHT")
  79. partymf_hpFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
  80. partymf_hpFrame:RegisterEvent("UNIT_HEALTH")
  81. partymf_hpFrame:SetScript("OnShow", function() partymf_hpFrame:RegisterEvent("UNIT_HEALTH") end)
  82. partymf_hpFrame:SetScript("OnHide", function() partymf_hpFrame:UnregisterEvent("UNIT_HEALTH") end)
  83. partymf_hpFrame:SetScript("OnEvent", function(frame, _, unit)
  84. if unit and not UnitIsUnit(unit, "party1") then return end
  85. local hp = UnitHealth("party1")
  86. if hp > 0 then
  87. hp = hp / UnitHealthMax("party1") * 100
  88. frame.text:SetFormattedText("%.1f%%", hp)
  89. else
  90. frame.text:SetText("0%")
  91. end
  92. end)
  93. -- end;
Add Comment
Please, Sign In to add comment