WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Need some help with secure hooking (https://www.wowinterface.com/forums/showthread.php?t=57390)

Walkerbo 08-26-19 07:27 PM

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.

kurapica.igas 08-27-19 02:59 AM

The hook secure part works fine, maybe you could post more code, so we can find the real problem.

I don't think use BAG_OPEN/BAG_CLOSED is a good choice since open/close bag is an ui action, it won't trigger the system event, you may try the BAG_UPDATE event for an example, so you can just move one item to another bag slot to trigger it.

Ketho 08-27-19 07:51 AM

Quote:

Originally Posted by Walkerbo (Post 333376)
yet I still have not been able to get any results when I run my code.

Quote:

Originally Posted by kurapica.igas (Post 333380)
The hook secure part works fine, maybe you could post more code, so we can find the real problem.

I don't think use BAG_OPEN/BAG_CLOSED is a good choice since open/close bag is an ui action, it won't trigger the system event


This. Tell us more clearly what you're trying to do and post your full code
You just want to know when any of the bags gets opened rather than the backpack?

https://us.forums.blizzard.com/en/wo...hooking/265975

Walkerbo 09-17-19 06:00 PM

Hi kurapica and Ketho

Sorry for the delayed reply, I am back on deck and ready to go.

You are both right the hook function is working perfectly, the issue was that I had not disabled the bag addon that I run, so a real boneheaded mistake.

My goal is to have a function run when the either the backpack, equipped bag, guild bank or the player bank open and close.

I want to hook that trigger but when I download and check other bag addons I have had very little success in understanding how and where they hook the function.

Is there a way to determine for each bag addon what or where the hooking function resides?

Fizzlemizz 09-17-19 06:12 PM

At a guess, other addons are possibly hooking the Blizzard OpenBag(id, force), CloseBag(id) functions for bags.

GUILDBANKFRAME_OPENED/GUILDBANKFRAME_CLOSED
BANKFRAME_OPENED/BANKFRAME_CLOSED

kurapica.igas 09-17-19 08:15 PM

Quote:

Originally Posted by Walkerbo (Post 333846)
Hi kurapica and Ketho

Sorry for the delayed reply, I am back on deck and ready to go.

You are both right the hook function is working perfectly, the issue was that I had not disabled the bag addon that I run, so a real boneheaded mistake.

My goal is to have a function run when the either the backpack, equipped bag, guild bank or the player bank open and close.

I want to hook that trigger but when I download and check other bag addons I have had very little success in understanding how and where they hook the function.

Is there a way to determine for each bag addon what or where the hooking function resides?

You can use /fstack to check the bag addon's frame name, and use frame:HookScript("OnShow", func) frame:HookScript("OnHide", func) to check them. It's more better than use secure hook.

Walkerbo 09-18-19 05:03 PM

Hi Ketho, Fizzlemizz and kurapica

Thank you all for your help and advice, I really appreciate these great communities and how helpful your responses are.

Once again thanks.


All times are GMT -6. The time now is 02:24 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI