View Single Post
05/26/14, 12:27 AM   #4
lyravega
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 93
Thanks for the replies. I am using this API function: "IsPlayerInAvAWorld()". I don't know if this returns true for anywhere else than Cyrodiil, I don't think so.

Right now I decided to use "EVENT_PLAYER_ACTIVATED" to register some other events; it will check the function above (IsPlayerInAvAWorld) and the user's choice (whether or not to have some features on or off in Cyrodiil), then register the events if they haven't been registered, or unregister them if they have been registered. Otherwise, I'll have to do the same check in the handler functions, which I'm trying to avoid (why do it over and over instead of doing it once)

Something like this (do not mind the order):
Lua Code:
  1. EVENT_MANAGER:RegisterForEvent( "QB" , EVENT_ADD_ON_LOADED , QB_Initialize )
  2.  
  3. local function QB_Initialize()
  4. ...
  5. EVENT_MANAGER:RegisterForEvent( "QB" , EVENT_PLAYER_ACTIVATED , QB_Cyrodiil )
  6. end
  7.  
  8. local function QB_Cyrodiil()
  9. if IsPlayerInAvAWorld()
  10. and QB_DisableFeaturesInCyrodiil
  11. and QB_EventsRegisteredBefore
  12. then UnregisterEvents()
  13. elseif not QB_EventsRegisteredBefore
  14. then RegisterEvents()
  15. else d("DERP, call 911") end
  16. end

I'm thinking this would suffice. Instead of doing the if-checks in the handler functions everytime their events fire, I'll be doing this check whenever "EVENT_PLAYER_ACTIVATED" fires. Wish there were two events called as "EVENT_CAMPAIGN_JOINED" and "EVENT_CAMPAIGN_LEFT" or something similar, that way I could save even more if-checks. Actually, going to add it to the wish list, who knows.

Meanwhile, can I create such a custom event? (Garkin and Seerah, you may now remember my name as I've asked you two how to create custom events, thanks to your helps but I still have no clue for some reason )
  Reply With Quote