Thread Tools Display Modes
10-08-10, 11:47 PM   #1
clix
A Murloc Raider
Join Date: Nov 2009
Posts: 9
enable/disable addon based on class.

I am trying to make a addon that enables/disables other addons based on the character class.

exp.
If class = hunter & addon = XXXX is not on, enable it
or
if class is not = hunter & addon "hunter addon" is enabled, disable addon.

coding exp (currently not working)

Code:
local playerClass, englishClass = UnitClass("player");

if (playerClass == "Hunter") then
    if not (IsAddOnLoaded("Tyra Misdirection")) then
       EnableAddOn("Tyra Misdirection")
       ReloadUI()
    end
end

if (playerClass == "Rogue") then
    if (IsAddOnLoaded("Tyra Misdirection")) then
       DisableAddOn("Tyra Misdirection")
       ReloadUI()
    end
end
The code is currently reading that the class is indeed hunter/rogue. But isn't doing anything beyond that.
  Reply With Quote
10-09-10, 12:35 AM   #2
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
You can select addons to be loaded in the addon settings for each char.
Guess thats faster than writing an addon.
Or you can ask the addonauthors to add support for

http://www.wowwiki.com/AddonLoader

which can load addons classbased and does not need an uireload.
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
10-09-10, 12:40 AM   #3
clix
A Murloc Raider
Join Date: Nov 2009
Posts: 9
Originally Posted by Rilgamon View Post
You can select addons to be loaded in the addon settings for each char.
Guess thats faster than writing an addon.
Or you can ask the addonauthors to add support for

http://www.wowwiki.com/AddonLoader

which can load addons classbased and does not need an uireload.

I know I am able to do it via wow settings. But just trying to do it via addon so I don't have to worry about it upon switching computers, which I seem to do a lot.
  Reply With Quote
10-09-10, 06:45 AM   #4
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
http://www.wowwiki.com/API_ReloadUI

The function ReloadUI is protected. Which means you cant call it without
the user clicking key or mouse. So you would need to create a button
to prompt for the reload when needed.
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
10-09-10, 07:53 AM   #5
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Not to mention most addons that are class specific have their own class loaders in them. I know mine do....
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
10-14-10, 10:12 AM   #6
mentalnutsy
A Cyclonian
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 47
What i do with Nutty War Announce is have the addon disable for next login if the class that logs in with it is not a warrior. You should be able to edit the below code to suit yourself easy enough.

Code:
function NuttyWarAnnounce:OnInitialize()
if select(2,UnitClass("player")) == "WARRIOR" then
    print("|cffFF0000Nutty War Announce:|r |cff00FF00Enabled|r")
	    elseif not Warrior then
    print("|cffFF0000Nutty War Announce:|r |cff00FF00Not a warrior. Disabling addon for next login|r")
      DisableAddOn("NuttyWarAnnounce")
      enabled = false
end

end

Edit: Sorry read the thread wrong. Hope this can be of some use tho.

Last edited by mentalnutsy : 10-14-10 at 10:18 AM.
  Reply With Quote
10-16-10, 12:24 AM   #7
Nuggs
A Deviate Faerie Dragon
 
Nuggs's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 19
what i do with my warlock addon is

Code:
local function nDemonic_Disable()
	DisableAddOn("nDemonic");
	ReloadUI();
end

StaticPopupDialogs["DISABLE_NDEMONIC"] = {
	text = "You're not currently logged into a warlock, disabling the AddOn.",
	button1 = "Accept", OnAccept = nDemonic_Disable, timeout = 0, whileDead = 1,
};

function nDemonic:PLAYER_LOGIN()
	if (select(2,UnitClass("player")) == "WARLOCK") then
		nDemonic:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
		nDemonic:RegisterEvent("PLAYER_DEAD");
		nDemonic:RegisterEvent("ZONE_CHANGED_NEW_AREA");
	else
		StaticPopup_Show("DISABLE_NDEMONIC");
	end
	nDemonic:UnregisterEvent("PLAYER_LOGIN");
end
Reason for that is I think you have to invoke the reloading of the UI through clicking instead of having it reload without user interaction.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » enable/disable addon based on class.


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