Unload event
Hey guys!
Anyone knows if it's possible to do stuff, when the player logs out or quits the game client? So I could update saved variables when that happens? Basically the direct opposite of EVENT_ADD_ON_LOADED? Thanks! |
maybe you can hook the click on the OK button from the deconnexion confirmation? or just the "show this control" to leave time to your commands to execute.... but i dunno how to /zgoo mouse this thing, good luck :D
baaah you can /zgoo mouse the "log out" line in the Esc menu for a start. is it for something you can't do at next startup at all, or update during the session? i can't find any example of it being strictly necessary... do you mind sharing some spoilers please? <-- insert pic of puss in boots reedit mmmh maybe saving your location for other toons to be able to check it? re reedit : maybe saving your last bag content without having to use on_single_slot_update? (can we make a game of this? the one who guesses what you are trying to do get a free copy of your addon... hmm or something like that) |
Quote:
You can: - Use the EVENT_PLAYER_DEACTIVATED: But it is not called on logout, only. - Hook Logout (Security allows it?) - Hook ESO_Dialogs["LOG_OUT"].buttons[1].callback |
You don't have to do this.
When player logout, reloadui, change cvar or get kicked for inactivity, saved variables are automatically saved. there's nothing to do. You must not prehook or use those events if it's for saved variables usage. For people who want to to this, here's how I do : At ADD_ON_LOADED : - I set a flag, this one goes to saved var. it will be used to guess at next ADD_ON_LOADED what kind of exit user did. If there's nothing to do at next add_on_loaded specifically for this kind of exit, don't do this. Lua Code:
But I repeat, if it's just only to save things on SavedVars, do not use this trick. It's mainly used for addons which store things per session and don't want thoses ones being resetted after a reloadui or a characer change. typical example : the chatbox being wiped, or stats. (KillCounter is a very good exemple too). some DPS meter could use this too but it's less important. |
That was exactly what I was looking for, albeit you stating several times not to use those hooks.
I've created a small addon which adds an all parameter to the /played command, so you could see the time you played all of your characters. So I needed to save the time played for each character at the latest time possible. Thanks for your help guys, as always! |
i suppose this would be no big deal to trigger EVENT_PLAYER_DEACTIVATED a few more times during the session for this since it's not the nasa BD you are trying to record here.
seems like the simplest, imo. good luck anyway you choose. |
Quote:
|
the advantage of the hook is that you can count the loading times in your stats. They might be a big % of it when you stay in towns doing some errands :D
other than that i'm sure anyone with a little less concerns than you would have used an update function. So, as far as i'm concerned i'll trust your solution. (i'm assuming you're using gettimestamp() right ?) |
Quote:
|
Have you considered just running a simple Update loop that saves GetSecondsPlayed() to the ZO_SavedVars every second, or even every 5 seconds (if margin of error of 5 seconds is pretty reasonable)? It doesn't save to the file until reload / logout, and you can be as confident as anyone else is that it will get saved, so you only need to worry about getting the data to the table. It's simple, reasonably efficient, and doesn't require anything fancy.
|
Yeah, I did consider this and that's actually how it was built just before I implemented the PreHook solution. I didn't really like polling the game all the time for a value, I only need right before it is stored to file, so I thought of that solution to be the most efficient.
|
I know this is an old topic, but I can't seem to find an answer anywhere: when does "SetCVar" happen? "ReloadUI", "Logout" and "Quit" are self-explanatory, but I'm not sure about "SetCVar". If I use ZO_PreHook("SetCVar"..), when will it fire? All I can find it being used with is changing the language... Is that it?
And another quick question - is there a way to ZO_PreHook somehow so that my function happens after the logout/quit countdown? So far for me it's happening right before the counter starts, but then I can just press cancel and stay in-game, which isn't exactly what I'm looking for. |
SetCVar is always happening then as you use it to change a setting/variable in-game.
Can be the language but also something like the video settings, audio settings etc. After the logout countdown the game will log you out and there is no way to run code at this point. It could happen too fast I guess. I think as the logout countdown is not always shown the PreHook to Logout() is either as the countdown starts or the game logs you out directly (but you won#t see anything in chat then anymore :-) ) |
All times are GMT -6. The time now is 05:39 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI