WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   "PLAYER_ALIVE" Alternative? (https://www.wowinterface.com/forums/showthread.php?t=30468)

suicidalkatt 02-05-10 02:02 AM

"PLAYER_ALIVE" Alternative?
 
Is there any particular reason why PLAYER_ALIVE doesn't fire on log in?

I've read the events to which it fires, but using it in the addon load sequence hasn't worked for me.

It just simply isn't triggering.

Any ideas?

nightcracker 02-05-10 03:49 AM

I personally use "PLAYER_ENTERING_WORLD" for pretty much everything exept savedvar for which I use "ADDON_LOADED".

Xrystal 02-05-10 04:08 AM

I used PLAYER_ENTERING_WORLD as well as VARIABLES_LOADED. I use ADDON_LOADED when I need to but most of the time I can avoid it.

Dridzt 02-05-10 04:23 AM

PLAYER_ALIVE fires for first logon but not for ReloadUI.

As a rule of thumb:
If you need to delay initialization of something on a clean start (entering the game from the account selection level) you can use PLAYER_ALIVE as it will fire after PLAYER_ENTERING_WORLD.

If you need to do the same after a reload (or entering the game after logging out to the character selection screen only) you can use PLAYER_ENTERING_WORLD and it will have the same effect.
(things that might not be available to the client at P_E_W on a clean start will be after a reload and for the rest PLAYER_ALIVE is usually delayed enough)

Bottomline if you need to use one of them, use both :p and unregister when you've done what you want to do.

Ailae 02-05-10 04:55 AM

Yeah, Dridzt is right, it will only fire on a "cold" login so to speak. If you're using PLAYER_ALIVE to know when talents are available you can register for PLAYER_ENTERING_WORLD and when it fires do this:

lua Code:
  1. if (GetNumTalentTabs() == 0) then
  2.     frame:RegisterEvent("PLAYER_ALIVE")
  3. else
  4.     -- talents are available already, so this was probably a /reload.
  5. end

SDPhantom 02-05-10 01:42 PM

I usually use PLAYER_LOGIN. It fires when everything's ready and only fires at loading.

ArrchDK 02-05-10 01:56 PM

Quote:

Originally Posted by SDPhantom (Post 177481)
I usually use PLAYER_LOGIN. It fires when everything's ready and only fires at loading.

IIRC and if they haven't changed it in the past year, talents aren't available at this time.

I don't recall being able to use player entering world either, but I may have been mistaken. I think I would set a primary OnUpdate function to keep checking until talents were available, then when they were, switch back to the regular onupdate.

Xrystal 02-05-10 02:06 PM

Well, PLAYER_ENTERING_WORLD is used for when zoning in and out of instances as well and from what wowwiki says is at the point where all frames need to be completed for display. I suspect that means that everything should be available at this stage.

Ailae 02-05-10 02:24 PM

According to the info on WoWWiki, talents are not available until PLAYER_ALIVE (unless you're doing a /reload).

http://www.wowwiki.com/AddOn_loading_process

suicidalkatt 02-05-10 02:40 PM

Thank you all for your suggestions. The player alive trigger seems to only work on a non' player generated load screen. (ie /reload )

Which I had no clue of, anyway thanks again for your suggestions. My problem has been solved :)

Edit: And for those curious, I was intending on using it for talent data. And rather than do multiple calculations, I'd much rather have it run only once and properly :).

SDPhantom 02-05-10 03:37 PM

PLAYER_ALIVE fires when any spell resurrects the player (after the player has accepted of course), this also triggers for the LOGINEFFECT spell that procs when you log in (I guess you get resurrected from the void or something :rolleyes:). Note it doesn't fire when the player runs to their body and resurrects that way. It isn't that relevant to the loading process, but do whatever you have to.

ArrchDK 02-05-10 07:14 PM

Quote:

Originally Posted by Xrystal (Post 177487)
Well, PLAYER_ENTERING_WORLD is used for when zoning in and out of instances as well and from what wowwiki says is at the point where all frames need to be completed for display. I suspect that means that everything should be available at this stage.

True, but any event fired upon load-up and reloadui can be used. You simply register the event OnLoad and unregister the event after it runs; meaning it only runs once - the time you log in.

v6o 09-15-10 03:44 AM

So I was making something that requires knowing when talent information is available and that's PLAYER_ALIVE on login and basically any time after on /reload's or loading screens.

Now I don't want to save variables if it's not necessary but I'm not finding another way of doing this.
The only way I can think of is saving a variable to say we're logged in and talents are available when first logging in (first PLAYER_ALIVE.. does this fire on login to Ghost/Dead?) and then resetting it when logging out.

Edit: Wrote PLAYER_LOGIN in first sentence when I meant PLAYER_ALIVE
Edit2: PLAYER_ALIVE does fire as ghost on log in.

yj589794 09-15-10 04:18 AM

Quote:

Originally Posted by v6o (Post 206230)
So I was making something that requires knowing when talent information is available and that's PLAYER_LOGIN on login and basically any time after on /reload's or loading screens.

Now I don't want to save variables if it's not necessary but I'm not finding another way of doing this.
The only way I can think of is saving a variable to say we're logged in and talents are available when first logging in (first PLAYER_ALIVE.. does this fire on login to Ghost/Dead?) and then resetting it when logging out.


You could register PLAYER_LOGIN to capture the first login, and then when you handle that event you unregister PLAYER_LOGIN and register PLAYER_ENTERING_WORLD.
This will allow you to capture all login and reloadui scenarios without having to use saved variables. It will have the disadvantage of being called everytime you get the loading screen though (Hearth, portal, entering/leaving instances, etc.)


something like this:
Code:

local myFrame = CreateFrame('Frame')
myFrame:RegisterEvent('PLAYER_LOGIN')

myFrame:PLAYER_LOGIN(event)
        -- handle first login

        self:UnregisterEvent('PLAYER_LOGIN')
        self:RegisterEvent('PLAYER_ENTERING_WORLD')
end

myFrame:PLAYER_ENTERING_WORLD(event)
        -- handle reloadui and changing zones
end

myFrame:SetScript('OnEvent', function(self, event, ...)
        self[event](self, event, ...)
end)


v6o 09-15-10 05:03 AM

As you probably noticed I edited my post a bit. The talent information is not available at PLAYER_ENTERING_WORLD (or PLAYER_LOGIN as it fires before P_E_W). When PLAYER_ALIVE fires during logins that's when the information is available.

Edit: Basically, on first log in, wait for PLAYER_ALIVE then register P_E_W and unregister PLAYER_ALIVE and only use P_E_W. Problem there is when a user does /reload PLAYER_ALIVE won't fire and P_E_W wouldn't get registered.

Ailae 09-15-10 05:29 AM

Did you look at the code I posted earlier?

If you register for PLAYER_ENTERING_WORLD and when it fires you check if talent-data is available. If not, this is a fresh login so register PLAYER_ALIVE. If the data is available, it was a /reload.

Or am I misunderstanding what you are after?

v6o 09-15-10 05:38 AM

Uhhh..... Uhhhh.... :rolleyes:

I should probably stop doing this stuff when I'm tired... but it's like the only time I have


All times are GMT -6. The time now is 12:42 PM.

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