-
August 20th, 2021, 03:28 #1
- Join Date
- Mar 2020
- Location
- Sydney, Australia
- Posts
- 247
Does User.onLogin Actually Trigger on a User Logging Out?
The handler User.onLogin gives a signature of onLogin(username, activated).
I have no problems overriding this and doing things on the login of a user (activated = true), however it is never triggered when the user is logging out.
In addition, when a user logs out (quits the program) and I try to send an OOB message, that message is never sent (assuming that them quitting the program has unloaded all relevant classes).
Any ideas on a work around to this? I am happy to use either option, just would like a log out trigger.
... And why some might ask? Because I have a set of windows open, one per user, and thus when they leave I wish to close that window.Thanks In Advance,
D
-
August 20th, 2021, 04:47 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,541
Yes, onUserLogin returns either true or false depending on whether a user is connecting or disconnecting. It will only fire on the GM client.
At the point that the user is disconnecting, you can no longer send messages to the user; since the user is already disconnected at that point.
Regards,
JPG
-
August 20th, 2021, 04:56 #3
- Join Date
- Mar 2020
- Location
- Sydney, Australia
- Posts
- 247
I have tried the following scenarios ...
In all cases it is the Host who is trying to check for login/logout - no one else (at this point)
1. onInit/onClose
The user sends a disconnect OOB message which is being listened for by the Host.
The message is never received - it does receive the connect OOB message however without a problem in the onInit()
2. onLogin
The host is watching for login true/false using my own onLogin code ... it sees the connection/disconnection in that function, however it is not able to continue with some code that relies on the Session.IsHost and the activated being true/false - that is, can the host actually see the disconnection?Thanks In Advance,
D
-
August 20th, 2021, 05:10 #4
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,541
That script event is fired on the GM client at the same time that the connected/disconnected messages are posted to chat. Here's a super simple extension that triggers on that event.
Regards,
JPG
-
August 20th, 2021, 05:13 #5
- Join Date
- Mar 2020
- Location
- Sydney, Australia
- Posts
- 247
Thank you for that ... it looks (in essence) identical to what I have except I am setting onLogin within a loaded LUA file rather than in the extension.xml
Would that make a difference?Thanks In Advance,
D
-
August 20th, 2021, 05:48 #6
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,541
No, it shouldn’t. Put a debug statement at the top of your function, and test with a localhost player client.
Does the extension trigger correctly?
JPG
-
August 20th, 2021, 05:56 #7
- Join Date
- Mar 2020
- Location
- Sydney, Australia
- Posts
- 247
Yes I was already Debugging the onLogin. It triggers on both instances
I then have code in that function like this - note that onUserLoginPrev is a store of the previous User.onLogin function - this is mainly not to interfere with any onLogin functionality that the ruleset may have and/or another extension relies upon.
The script is NOT seeing the "ATTEMPTING TO DISCONNECT" and "EXECUTING PREVIOUS LOGIN" sections.
Code:function onLogin(username, activated) Debug.chat("MY ON LOGIN", username, activated) if activated and onUserLoginPrev then onUserLoginPrev(username, activated) if Session.IsHost then if activated then localTable.connect(username) else Debug.chat("ATTEMPTING TO DISCONNECT") localTable.disconnect(username) end end if not activated and onUserLoginPrev then Debug.chat("EXECUTING PREVIOUS LOGIN") onUserLoginPrev(username, activated) end end
Thanks In Advance,
D
-
August 20th, 2021, 06:22 #8
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,541
OnUserLogin is only for the GM client; not for running on player clients.
JPG
-
August 20th, 2021, 07:09 #9
- Join Date
- Mar 2020
- Location
- Sydney, Australia
- Posts
- 247
And the code is not running on a user client technically ... that is why I have the Session.IsHost in the code ... to ensure that even if a IsUser gets in, it will not run the code. It might be redundant but it should not stop the code from executing should it?
Thanks In Advance,
D
-
August 20th, 2021, 07:48 #10Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks