Search Unity

Resolved Steam Invites - GetLaunchCommandLine Not Working..

Discussion in 'Multiplayer' started by brilliantgames, Aug 5, 2021.

  1. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    We are working on Steam invites for our title on Steam which uses photon networking. So far we have in game invites working perfectly, but we are unable to get the steam launch command to give us anything when a user is invited while not running the game.

    When we return the Steam launch command while running in Steam, it's just a blank string. Anyone have any experience with this?

    Here is the snippet of debug code we are using which displays the launch command on GUI. We run this in a test app on steam and have another user invite to game. Nothing is displayed on the command line out.


    Code (CSharp):
    1.    if (SteamManager.Initialized)
    2.         {
    3.  
    4.             string CommandLine = "";
    5.             int ret = SteamApps.GetLaunchCommandLine(out CommandLine, 260);
    6.  
    7.             GUI.Label(new Rect(Screen.width / 2, Screen.height -30, 800, 30), "Command line is: "+CommandLine);
    8.  
    9.         }
     
  2. bosko0509

    bosko0509

    Joined:
    Apr 13, 2018
    Posts:
    4
    Running into the same problem, did you find a solution?
     
  3. Deleted User

    Deleted User

    Guest

    Hello, I know this is an old post but I got lost on this for 20 minutes of googling with no luck and thought the answer might be useful to someone. The steam api is a bit vague and tells you to get them out with the api, however that returns empty.

    So, I did some googling, and tried a few different methods via the SteamAPI.
    No luck, but it occured to me that I am a fool...

    These are command line arguments. And sure enough they did exist if you looked at them in task manager when you start your game via an invite. Once i saw that I face palmed.

    You can get them out with something like the following
    Code (CSharp):
    1.  
    2.             // get your command line arguments
    3.             var args = System.Environment.GetCommandLineArgs();
    4.  
    5.             // we really only care if we have 2 or more if we just want the lobbyid.
    6.             if (args.Length >= 2)
    7.             {
    8.                 // loop to the 2nd last one, because we are gonna do a + 1
    9.                 // the lobbyID is straight after +connect_lobby
    10.                 for (int i = 0; i < args.Length - 1; i++)
    11.                 {
    12.                     if (args[i].ToLower() == "+connect_lobby")
    13.                     {
    14.                         if (ulong.TryParse(args[i + 1], out ulong lobbyID))
    15.                         {
    16.                             if (lobbyID > 0)
    17.                             {
    18.                                 // do something with your lobby id
    19.                             }
    20.                         }
    21.                         break;
    22.                     }
    23.                 }
    24.             }
    25.  
     
    The501legion likes this.
  4. silvergat

    silvergat

    Joined:
    Jun 11, 2020
    Posts:
    22
    guys im stuck how do i add steam invites with photon lobby please help
     
    valentin56610 likes this.