View Single Post
01-22-17, 08:18 AM   #1
wille480
A Wyrmkin Dreamwalker
Join Date: Jan 2017
Posts: 56
button("OnClick") & PLAYER_ENTERING_WORLD

Hey guys!
this is the code i have now! , this code does so if mybutton2 is clicked it will run the second code below the line and print out "HelyaAssist is now Disabled" , nothing with the code broken so far but that will be printed everytime i release from graveyard, reloadui manually and so on.. I only want that code to go off if mybutton2 is clicked. How do i do this? have tried alot of things like if statements and stuff but then i get an error ingame saying that it failed cuz it is trying to call frame a global nil value.

Lua Code:
  1. mybutton2:SetScript("OnClick", function(self, button, down)
  2.  local playerName = UnitName("player")
  3.  DisableAddOn(folder, playerName)
  4.  ReloadUI()
  5.  eventHandlerE();
  6. end)
  7.  
  8. ------------------------------------
  9.  
  10. local frame = CreateFrame("FRAME", "FooAddonFrame");
  11. frame:RegisterEvent("PLAYER_ENTERING_WORLD");
  12. local function eventHandlerE(self, event, ...)
  13. print('|cffffff00HelyaAssist is now Disabled')
  14.  end
  15. frame:SetScript("OnEvent", eventHandlerE);

tried this for example but did not work :/
Lua Code:
  1. local ds = 0
  2.  
  3. mybutton2:SetScript("OnClick", function(self, button, down)
  4.  local playerName = UnitName("player")
  5.  DisableAddOn(folder, playerName)
  6.  ReloadUI()
  7.  ds = 1
  8. end)
  9.  
  10. ------------------------------------
  11. if ds == 1 then
  12. local frame = CreateFrame("FRAME", "FooAddonFrame");
  13. frame:RegisterEvent("PLAYER_ENTERING_WORLD");
  14. local function eventHandlerE(self, event, ...)
  15. print('|cffffff00HelyaAssist is now Disabled')
  16.  end
  17. end
  18. frame:SetScript("OnEvent", eventHandlerE);

Best regards!

Last edited by wille480 : 01-22-17 at 08:21 AM.
  Reply With Quote