Quantcast friendly nameplate remove healthbar - WoWInterface
Thread Tools Display Modes
04-16-20, 02:47 PM   #1
Igorcovran
A Murloc Raider
Join Date: Apr 2020
Posts: 4
friendly nameplate remove healthbar

Hello.
I found something i need on tihos forums <3

so its class icon for friendly players
Code:
local iconKey = addonName .. "Icon"

local GetNamePlateForUnit = C_NamePlate.GetNamePlateForUnit

local iconTexture = {
    ["DEATHKNIGHT"] = 135771,
    ["DEMONHUNTER"] = 236415,
    ["DRUID"] = 625999,
    ["HUNTER"] = 626000,
    ["MAGE"] = 626001,
    ["MONK"] = 626002,
    ["PALADIN"] = 626003,
    ["PRIEST"] = 626004,
    ["ROGUE"] = 626005,
    ["SHAMAN"] = 626006,
    ["WARLOCK"] = 626007,
    ["WARRIOR"] = 626008
}

local frame = CreateFrame("Frame")
 
frame:SetScript("OnEvent", function(self, event, unit)
    local namePlate = GetNamePlateForUnit(unit)
    if event == "NAME_PLATE_UNIT_ADDED" and UnitIsFriend("player", unit) then
        local _, class = UnitClass(unit)
        if iconTexture[class] then
            local icon = namePlate[iconKey]
            if not icon then
                icon = namePlate:CreateTexture(nil, "OVERLAY")
                icon:SetPoint('CENTER', 0, 22)
                icon:SetSize(22, 22)
                namePlate[iconKey] = icon
            end
            icon:SetTexture(iconTexture[class])
            icon:Show()
            return
        end
    end
    if namePlate[iconKey] then
        namePlate[iconKey]:Hide()
    end
end)

frame:RegisterEvent("NAME_PLATE_UNIT_ADDED")
frame:RegisterEvent("NAME_PLATE_UNIT_REMOVED")
now the only problem is i want the name and healthbar gone from frindly nameplates ramianing just the class icon

https://ibb.co/KhLZ5SZ
  Reply With Quote
04-17-20, 10:24 AM   #2
Igorcovran
A Murloc Raider
Join Date: Apr 2020
Posts: 4
it cant be done?
  Reply With Quote
04-23-20, 07:05 AM   #3
sezz
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 110
Originally Posted by Igorcovran View Post
it cant be done?
friendly nameplates are protected in instances/pvp
  Reply With Quote
04-23-20, 10:28 AM   #4
Igorcovran
A Murloc Raider
Join Date: Apr 2020
Posts: 4
thanks for replay
  Reply With Quote
04-24-20, 05:36 AM   #5
Xruptor
A Flamescale Wyrmkin
 
Xruptor's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 121
Originally Posted by sezz View Post
friendly nameplates are protected in instances/pvp
Sezz pretty much hit it on the nail. You can't modify nameplates in instances or pvp, if you try to do so you will trigger taint errors and such. Blizzard did this to prevent nameplates from being used to calculate positioning and what not and other things they didn't want folks doing.

Outside of that scope you can modify them as you like. A question though? Why not just use the colored healthbars to know the class? It shouldn't be necessary to place a class icon. Even if you are color blind there are settings that can adjust that.

Otherwise you if you want to use that code you need to add measures to prevent errors.


Code:
local iconKey = addonName .. "Icon"

local GetNamePlateForUnit = C_NamePlate.GetNamePlateForUnit

local iconTexture = {
    ["DEATHKNIGHT"] = 135771,
    ["DEMONHUNTER"] = 236415,
    ["DRUID"] = 625999,
    ["HUNTER"] = 626000,
    ["MAGE"] = 626001,
    ["MONK"] = 626002,
    ["PALADIN"] = 626003,
    ["PRIEST"] = 626004,
    ["ROGUE"] = 626005,
    ["SHAMAN"] = 626006,
    ["WARLOCK"] = 626007,
    ["WARRIOR"] = 626008
}

local frame = CreateFrame("Frame")
 
frame:SetScript("OnEvent", function(self, event, unit)
	local inInstance, instanceType = IsInInstance()
	
	--make sure we aren't in an instance
	if not inInstance then
		--next check to see if you can even TOUCH the namePlate, using CanAccessObject
		local namePlate = GetNamePlateForUnit(unit)
		if namePlate and CanAccessObject(namePlate) then
	
			if event == "NAME_PLATE_UNIT_ADDED" and UnitIsFriend("player", unit) then
				local _, class = UnitClass(unit)
				if iconTexture[class] then
					local icon = namePlate[iconKey]
					if not icon then
						icon = namePlate:CreateTexture(nil, "OVERLAY")
						icon:SetPoint('CENTER', 0, 22)
						icon:SetSize(22, 22)
						namePlate[iconKey] = icon
					end
					icon:SetTexture(iconTexture[class])
					icon:Show()
					return
				end
			end
			if namePlate[iconKey] then
				namePlate[iconKey]:Hide()
			end
		
		end
	end
end)

frame:RegisterEvent("NAME_PLATE_UNIT_ADDED")
frame:RegisterEvent("NAME_PLATE_UNIT_REMOVED")
__________________
Click HERE for the ultimate idiot test.

if (sizeof(sadness) > sizeof(happiness)) { initDepression(); }
  Reply With Quote
04-30-20, 11:54 AM   #6
Igorcovran
A Murloc Raider
Join Date: Apr 2020
Posts: 4
rather have icons for friends and color hp bars for enemy just like thrille streemer
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » friendly nameplate remove healthbar

Thread Tools
Display Modes

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