Thread Tools Display Modes
02-05-10, 02:02 AM   #1
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
"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?
  Reply With Quote
02-05-10, 03:49 AM   #2
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
I personally use "PLAYER_ENTERING_WORLD" for pretty much everything exept savedvar for which I use "ADDON_LOADED".
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
02-05-10, 04:08 AM   #3
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
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.
__________________
  Reply With Quote
02-05-10, 04:23 AM   #4
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,359
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 and unregister when you've done what you want to do.
  Reply With Quote
02-05-10, 04:55 AM   #5
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
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
__________________
Oh, the simulated horror!
  Reply With Quote
02-05-10, 01:42 PM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
I usually use PLAYER_LOGIN. It fires when everything's ready and only fires at loading.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
02-05-10, 01:56 PM   #7
ArrchDK
A Fallenroot Satyr
 
ArrchDK's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 25
Originally Posted by SDPhantom View Post
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.
  Reply With Quote
02-05-10, 02:06 PM   #8
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
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.
__________________
  Reply With Quote
02-05-10, 02:24 PM   #9
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
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
__________________
Oh, the simulated horror!
  Reply With Quote
02-05-10, 02:40 PM   #10
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
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 .
  Reply With Quote
02-05-10, 03:37 PM   #11
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
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 ). 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.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
02-05-10, 07:14 PM   #12
ArrchDK
A Fallenroot Satyr
 
ArrchDK's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 25
Originally Posted by Xrystal View Post
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.
  Reply With Quote
09-15-10, 03:44 AM   #13
v6o
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 399
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.
__________________
I stopped playing back World of Warcraft in 2010 and I have no plans on returning.
This is a dead account and if you want to continue any of my addons or make a fork then feel free to do so.
This is your permission slip.

If you need to contact me, do so on Twitter @v6ooo

Best regards, v6.

Last edited by v6o : 09-15-10 at 04:41 AM.
  Reply With Quote
09-15-10, 04:18 AM   #14
yj589794
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 314
Originally Posted by v6o View Post
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)

Last edited by yj589794 : 09-15-10 at 04:20 AM.
  Reply With Quote
09-15-10, 05:03 AM   #15
v6o
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 399
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.
__________________
I stopped playing back World of Warcraft in 2010 and I have no plans on returning.
This is a dead account and if you want to continue any of my addons or make a fork then feel free to do so.
This is your permission slip.

If you need to contact me, do so on Twitter @v6ooo

Best regards, v6.

Last edited by v6o : 09-15-10 at 05:16 AM.
  Reply With Quote
09-15-10, 05:29 AM   #16
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
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?
__________________
Oh, the simulated horror!
  Reply With Quote
09-15-10, 05:38 AM   #17
v6o
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 399
Uhhh..... Uhhhh....

I should probably stop doing this stuff when I'm tired... but it's like the only time I have
__________________
I stopped playing back World of Warcraft in 2010 and I have no plans on returning.
This is a dead account and if you want to continue any of my addons or make a fork then feel free to do so.
This is your permission slip.

If you need to contact me, do so on Twitter @v6ooo

Best regards, v6.

Last edited by v6o : 09-15-10 at 05:41 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » "PLAYER_ALIVE" Alternative?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off