1
\$\begingroup\$

The title describes the problem. I am trying to launch the game through an invite from a friend. When I accept the invite, it launches the game just fine. But when I try to then read the Command line through SteamApps.GetLaunchCommandLine() it does not contain the "+connect_lobby" that the documentation describes. There is very little I can find on this online.

What situations could cause the game to not start up with that line when it should? Is there an alternative?

I read the command line as intended, like this:

string steamCommandLine = "";
Steamworks.SteamApps.GetLaunchCommandLine(out steamCommandLine, 260);

Note that the OnGameRichPresenceJoinRequested callback works perfectly as intended.

We have a custom parameter that does go through. Would it be possible that this parameter overwrites the rest of the command line?

After I did a bit more research, and in the steam console (with spew level 4 4) I found that steam executes a url: ExecuteSteamURL: "steam://rungame/<appID>/<steamID64>/GuideHouse". That steamID is exactly what I want, but I am not able to retrieve it in code...

\$\endgroup\$
3
  • \$\begingroup\$ I notice the documentation says 'In order for rich presence joins to go through this and not be placed on the OS command line, you must enable "Use launch command line" from the Installation > General page on your app.' — can you show us the configuration of this page? \$\endgroup\$
    – DMGregory
    Jul 1, 2021 at 12:14
  • \$\begingroup\$ @DMGregory I can confirm that this option is turned on. We noticed this setting as well, hoping it would fix the issue, but all it did was remove the popup... \$\endgroup\$
    – Dirk
    Jul 1, 2021 at 12:32
  • \$\begingroup\$ Did you ever resolve this? We have the same question. \$\endgroup\$ Oct 9, 2022 at 12:42

1 Answer 1

1
\$\begingroup\$

This forum post mentions a valid alternative that just retrieves the command line argument using Base Class Libraries:

https://forum.unity.com/threads/steam-invites-getlaunchcommandline-not-working.1152140/

Incase the link rots here is the solution it documents:

        // get your command line arguments
    var args = System.Environment.GetCommandLineArgs();

    // we really only care if we have 2 or more if we just want the lobbyid.
    if (args.Length >= 2)
    {
        // loop to the 2nd last one, because we are gonna do a + 1
        // the lobbyID is straight after +connect_lobby
        for (int i = 0; i < args.Length - 1; i++)
        {
            if (args[i].ToLower() == "+connect_lobby")
            {
                if (ulong.TryParse(args[i + 1], out ulong lobbyID))
                {
                    if (lobbyID > 0)
                    {
                        // do something with your lobby id
                    }
                }
                break;
            }
        }
    }

I've just tested this myself and it works fine. No idea why Steamworks.NETs/ SteamAPIs implementation doesn't correctly manage to get normal commandline arguments.

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .