Facepunch.Steamworks icon indicating copy to clipboard operation
Facepunch.Steamworks copied to clipboard

Add Steamworks.SteamServer.SteamId

Open JaySlex opened this issue 3 years ago • 2 comments

I looked up in the doc and it showed : https://wiki.facepunch.com/steamworks/SteamServer.SteamId, but it doesnt seems to exist.

Add a way to get the server steamId, unless it doesnt exist anymore, but I know it's still used in Steamworks.Net

JaySlex avatar Mar 28 '21 21:03 JaySlex

I was able to get this property using reflection (which isn't great)...

    static SteamId GetSteamId() {
      object steamGameServer =
          typeof(SteamServer)
              .GetProperty(
                  "Internal", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)
              .GetValue(null);

      return (SteamId) steamGameServer
          .GetType()
          .GetMethod(
              "GetSteamID", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)
          .Invoke(steamGameServer, null);
    }

redseiko avatar Nov 03 '21 22:11 redseiko

I was able to get this property using reflection (which isn't great)...

    static SteamId GetSteamId() {
      object steamGameServer =
          typeof(SteamServer)
              .GetProperty(
                  "Internal", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)
              .GetValue(null);

      return (SteamId) steamGameServer
          .GetType()
          .GetMethod(
              "GetSteamID", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)
          .Invoke(steamGameServer, null);
    }

I found how to access it directly, update to the last version by compilling it. Not the release

JaySlex avatar Nov 04 '21 00:11 JaySlex