DICE PACKS BUNDLE
  1. #1

    Join Date
    Mar 2020
    Location
    Sydney, Australia
    Posts
    247

    When A Client Connects ...

    Greetings,

    I have an extension that gives the GM a few options to turn on/off for their game.

    When this is done, an OOB message is sent to the client to perform some actions to enable these items.

    So far it works as intended, however when the client first logs in to the session, because the state of these items is controlled by the GM, they are "off" on the client side. The GM has to turn the item off/on for each client to send the OOB message etc.

    Is there a way for the host to recognise a connection and send the OOB messages immediately?
    Thanks In Advance,
    D

  2. #2
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,678
    Blog Entries
    1
    You could try:

    Code:
    onLogin
    
    function onLogin(username, activated)
    Registered functions on this handler are called whenever a user logs in to or out of the running session.
    
    Parameters
    
    username   (string)   
    The username of the connecting/disconnecting client
    
    activated   (boolean)   
    This value is true if the user is logging on, or false if the user is logging off

  3. #3

    Join Date
    Mar 2020
    Location
    Sydney, Australia
    Posts
    247
    I did look at that, however I would need to know the username of the person logging in wouldn't I?

    I am really looking for the client to say "hi I am here".
    Thanks In Advance,
    D

  4. #4
    The onLogin is a handler that you register a callback function to listen for, and gets passed the username parameter.

    Search through CoreRPG ruleset for an example of registering a handler; and handling the callback.

    Regards,
    JPG

  5. #5

    Join Date
    Mar 2020
    Location
    Sydney, Australia
    Posts
    247
    Okay, so I looked through CoreRPG and found only one location that it is used - scripts/data_desktop.lua/onInit

    The setup sets the callback User.onLogin to a function in that script - User.onLogin = onUserLogin

    If I takeover that callback with my own code - for example User.onLogin = myOnUserLogin, the default function will not execute, am I correct?

    I can ensure that the default code executes without an issue, however this still will cause problems in the future with any other extensions that hook User.onLogin.

    Have I understood that correctly?
    Thanks In Advance,
    D

  6. #6
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    Quote Originally Posted by UrsaTeddy View Post
    So far it works as intended, however when the client first logs in to the session, because the state of these items is controlled by the GM, they are "off" on the client side. The GM has to turn the item off/on for each client to send the OOB message etc.
    If the options are GM options, and not options that players can control, then when a player logs in the code should have access to the current options.

    Something to consider:
    1) Writing code that triggers when the client logs in. You can do this on the player side, but pass processing to the GM via OOB messaging or keep it locally if that's what you need (which it sounds like it is).. This may be simpler than triggering directly on the GM side via the onLogin event.
    2) And, having your current code that runs if the GM changes the option while players are connected.
    Private 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!

  7. #7

    Join Date
    Mar 2020
    Location
    Sydney, Australia
    Posts
    247
    The properties are GM only (turn property on/off, set a name for the property).

    I solved it with the client sending a "hi I am here" OOB to the host which then triggers an update/refresh for the client.

    I was actually able to also refresh any open character sheets since the options in question create/destroy character sheet fields.

    The comments here have been very helpful.
    Thanks In Advance,
    D

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Product Walkthrough Playlist

Log in

Log in