View Single Post
08-26-19, 07:27 PM   #1
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Need some help with secure hooking

Hi all

I am looking for a bit of guidance with hooking secure functions and/or triggering events for opening and closing the backpack.

I already have PLAYER_LOGIN, MERCHANT_SHOW and MERCHANT_CLOSED events working without issue.

On Townlong Yak I can find the BAG_OPEN and BAG_CLOSED events, as well as the ToggleBackpack, OpenBackpack and CloseBackpack functions yet I still have not been able to get any results when I run my code.

Here are my code chunks:

Lua Code:
  1. -- my hook functions
  2. hooksecurefunc(
  3.     "CloseBackpack",function()
  4.         print("CloseBackpack hookedfunction fired")
  5.     end
  6. )
  7. hooksecurefunc(
  8.     "OpenBackpack",function()
  9.         print("OpenBackpack hookedfunction fired")
  10.     end
  11. )
  12. hooksecurefunc(
  13.     "ToggleBackpack",function()
  14.         print("ToggleBackpack hookedfunction fired")
  15.     end
  16. )
Lua Code:
  1. -- my event triggers
  2. TestFrame:SetScript("OnEvent",function(self, event, ...)
  3.     if event == "BAG_OPEN" then
  4.         print("BAG_OPEN event triggered")
  5.     elseif event == "BAG_CLOSED" then
  6.         print("BAG_CLOSED event triggered")
  7.     end
  8. end
  9. )
  10. TestFrame:RegisterEvent("BAG_OPEN")
  11. TestFrame:RegisterEvent("BAG_CLOSED")
Any sort of guidance and explanation of where I am going wrong would be great.

Last edited by Walkerbo : 08-26-19 at 07:32 PM.
  Reply With Quote