public override void Open(string bindip, ushort port, bool lan) { if (bindip == "*") { bindip = "0.0.0.0"; } if (IsHosting) { return; } var ip = SteamworksCommon.GetUInt32FromIp(bindip); EServerMode mode = EServerMode.eServerModeAuthenticationAndSecure; //if(lan) mode = EServerMode.eServerModeNoAuthentication; if (!GameServer.Init(ip, (ushort)(port + 2), port, (ushort)(port + 1), mode, GameInfo.VERSION)) { throw new ServerInitializationFailedException("Couldn't start server (Steamworks API initialization failed)"); } SteamGameServer.SetDedicatedServer(!lan); SteamGameServer.SetGameDescription(GameInfo.NAME); SteamGameServer.SetProduct(GameInfo.NAME); SteamGameServer.SetModDir(GameInfo.NAME); SteamGameServer.SetServerName(Description); SteamGameServer.LogOnAnonymous(); SteamGameServer.SetPasswordProtected(false); //Todo SteamGameServer.EnableHeartbeats(true); Application.targetFrameRate = 60; IsHosting = true; }
//----------------------------------------------------------------------------- // Purpose: Called once we are connected to Steam to tell it about our details //----------------------------------------------------------------------------- void SendUpdatedServerDetailsToSteam() { // // Set state variables, relevant to any master server updates or client pings // // These server state variables may be changed at any time. Note that there is no lnoger a mechanism // to send the player count. The player count is maintained by steam and you should use the player // creation/authentication functions to maintain your player count. SteamGameServer.SetMaxPlayerCount(m_nMaxPlayers); SteamGameServer.SetPasswordProtected(false); SteamGameServer.SetServerName(m_strServerName); SteamGameServer.SetBotPlayerCount(0); // optional, defaults to zero SteamGameServer.SetMapName(m_strMapName); #if USE_GS_AUTH_API // Update all the players names/scores /* @TODO: Riley: Disabled * for (uint32 i = 0; i < MAX_PLAYERS_PER_SERVER; ++i) { * if (m_rgClientData[i].m_bActive && m_rgpShips[i]) { * SteamGameServer.BUpdateUserData(m_rgClientData[i].m_SteamIDUser, m_rgpShips[i]->GetPlayerName(), m_rguPlayerScores[i]); * } * }*/ #endif // game type is a special string you can use for your game to differentiate different game play types occurring on the same maps // When users search for this parameter they do a sub-string search of this string // (i.e if you report "abc" and a client requests "ab" they return your server) //SteamGameServer.SetGameType( "dm" ); // update any rule values we publish //SteamGameServer.SetKeyValue( "rule1_setting", "value" ); //SteamGameServer.SetKeyValue( "rule2_setting", "value2" ); }
private void SendUpdatedServerDetailsToSteam() { SteamGameServer.SetMaxPlayerCount(SteamDSConfig.ServerPlayers); SteamGameServer.SetPasswordProtected(false); SteamGameServer.SetServerName(SteamDSConfig.ServerName); SteamGameServer.SetBotPlayerCount(0); SteamGameServer.SetMapName(SteamDSConfig.MapName); }
private void SendUpdatedServerDetailsToSteam() { SteamGameServer.SetMaxPlayerCount(SteamDSConfig.ServerPlayers); SteamGameServer.SetPasswordProtected(!string.IsNullOrEmpty(SteamDSConfig.ServerPassword)); SteamGameServer.SetServerName(SteamDSConfig.ServerName); SteamGameServer.SetMapName(SteamDSConfig.MapName); SteamGameServer.SetGameTags(SteamDSConfig.ServerGUID + ";__E3C26D06F07B6AB14EC25F4823E9A30D6B4ED0450527C1E768739D96C9F061AE"); SteamGameServer.ForceHeartbeat(); }
private void OnSteamServersConnected(SteamServersConnected_t LogonSuccess) { _connectedToSteam = true; SteamGameServer.SetMaxPlayerCount(4); SteamGameServer.SetPasswordProtected(false); SteamGameServer.SetServerName("Snakes"); SteamGameServer.SetBotPlayerCount(0); SteamGameServer.SetMapName("inGame"); }
private void SendUpdatedServerDetailsToSteam() { SteamGameServer.SetMaxPlayerCount(SteamDSConfig.ServerPlayers); SteamGameServer.SetPasswordProtected(!string.IsNullOrEmpty(SteamDSConfig.ServerPassword)); SteamGameServer.SetServerName(SteamDSConfig.ServerName); SteamGameServer.SetMapName(SteamDSConfig.MapName); SteamGameServer.SetGameTags(SteamDSConfig.ServerGUID + ";__F486E3E06B8E13E0388571BE0FDC8A35182D8BE83E9256BA53BC5FBBDBCF23BC"); SteamGameServer.ForceHeartbeat(); }
private void ServerConnectedCallback(SteamServersConnected_t callback) { Debug.Log("[Steamworks.NET] GameServer connected successfully"); SteamGameServer.SetServerName(ServerConfig.ServerName); SteamGameServer.SetPasswordProtected(!string.IsNullOrEmpty(ServerConfig.Password)); SteamGameServer.SetMaxPlayerCount(ServerConfig.TeamNum * ServerConfig.NumPerTeam); SteamGameServer.SetMapName(ServerConfig.MapName); SteamGameServer.SetDedicatedServer(true); SetAdditionalGameInfo(); SteamGameServer.EnableHeartbeats(true); }
void SendUpdatedServerSteam() { SteamGameServer.SetMaxPlayerCount(4); SteamGameServer.SetPasswordProtected(false); SteamGameServer.SetServerName("Snakes"); SteamGameServer.SetBotPlayerCount(0); SteamGameServer.SetMapName("inGame"); #if USE_GS_AUTH_API for (uint i = 0; i < 4; ++i) { } #endif }
public static void SetModded() { try { using (TimeWarning.New("UpdateServerInformation", 0.1f)) { SteamGameServer.SetServerName(ConVar.Server.hostname); SteamGameServer.SetMaxPlayerCount(ConVar.Server.maxplayers); SteamGameServer.SetPasswordProtected(false); SteamGameServer.SetMapName(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name); string pchGameTags = string.Format("mp{0},cp{1},v{2}{3}{4}", new object[] { ConVar.Server.maxplayers, BasePlayer.activePlayerList.Count, Rust.Protocol.network, ConVar.Server.pve ? ",pve" : string.Empty, pluton.enabled ? ",modded,pluton" : string.Empty }); SteamGameServer.SetGameTags(pchGameTags); string[] array = ConVar.Server.description.SplitToChunks(100).ToArray <string>(); for (int i = 0; i < 16; i++) { if (i < array.Length) { SteamGameServer.SetKeyValue(string.Format("description_{0:00}", i), array[i]); } else { SteamGameServer.SetKeyValue(string.Format("description_{0:00}", i), String.Empty); } } SteamGameServer.SetKeyValue("country", SteamGameServerUtils.GetIPCountry()); SteamGameServer.SetKeyValue("world.seed", global::World.Seed.ToString()); SteamGameServer.SetKeyValue("world.size", global::World.Size.ToString()); SteamGameServer.SetKeyValue("official", ConVar.Server.official.ToString()); SteamGameServer.SetKeyValue("pve", ConVar.Server.pve.ToString()); SteamGameServer.SetKeyValue("headerimage", ConVar.Server.headerimage); SteamGameServer.SetKeyValue("url", ConVar.Server.url); SteamGameServer.SetKeyValue("uptime", ((int)Time.realtimeSinceStartup).ToString()); SteamGameServer.SetKeyValue("mem_ws", Performance.usedMemoryWorkingSetMB.ToString()); SteamGameServer.SetKeyValue("mem_pv", Performance.usedMemoryPrivateMB.ToString()); SteamGameServer.SetKeyValue("gc_mb", Performance.memoryAllocations.ToString()); SteamGameServer.SetKeyValue("gc_cl", Performance.memoryCollections.ToString()); SteamGameServer.SetKeyValue("fps", Performance.frameRate.ToString()); SteamGameServer.SetKeyValue("fps_avg", Performance.frameRateAverage.ToString("0.00")); SteamGameServer.SetKeyValue("ent_cnt", BaseNetworkable.serverEntities.Count.ToString()); SteamGameServer.SetKeyValue("build", BuildInformation.VersionStampDays.ToString()); } } catch (Exception ex) { Logger.LogError("[Hooks] Error while setting the server modded."); Logger.LogException(ex); } }
public static bool RegisterServer_modded(string name, bool password, string version, bool publicServer, string worldName, ZSteamMatchmaking __instance) { __instance.UnregisterServer(); SteamGameServer.SetServerName(config.ServerName); SteamGameServer.SetMapName(config.SteamMapName); SteamGameServer.SetPasswordProtected(password); SteamGameServer.SetGameTags(version); SteamGameServer.EnableHeartbeats(publicServer); SteamGameServer.SetMaxPlayerCount(config.Size); SteamGameServer.SetGameDescription("Valheim"); AccessTools.Field(typeof(ZSteamMatchmaking), "m_registerServerName").SetValue(__instance, config.ServerName); AccessTools.Field(typeof(ZSteamMatchmaking), "m_registerPassword").SetValue(__instance, password); AccessTools.Field(typeof(ZSteamMatchmaking), "m_registerVerson").SetValue(__instance, version); print("Registering lobby (modded)"); return(false); }
private void Start() { if (!SteamDSConfig.isDedicatedServer && !SteamManager.Initialized) { SteamManager.Reset(); } SteamDSConfig.MapName = GameSetup.Difficulty.ToString(); SteamDSConfig.manager.SetStart(this.loadAsync); bool flag = GameServer.Init(0u, SteamDSConfig.ServerSteamPort, SteamDSConfig.ServerGamePort, SteamDSConfig.ServerQueryPort, SteamDSConfig.ServerAuthMode, SteamDSConfig.ServerVersion); if (flag) { Debug.Log("GameServer init success. Port: " + SteamDSConfig.ServerGamePort); if (CoopDedicatedServerStarter.< > f__mg$cache0 == null) { CoopDedicatedServerStarter.< > f__mg$cache0 = new SteamAPIWarningMessageHook_t(CoopDedicatedServerStarter.SteamAPIDebugTextHook); } SteamGameServerUtils.SetWarningMessageHook(CoopDedicatedServerStarter.< > f__mg$cache0); SteamGameServer.SetModDir("theforestDS"); SteamGameServer.SetProduct(SteamDSConfig.ProductName); SteamGameServer.SetGameDescription(SteamDSConfig.ProductDescription); SteamGameServer.SetServerName(SteamDSConfig.ServerName); SteamGameServer.SetDedicatedServer(true); if (string.IsNullOrEmpty(SteamDSConfig.ServerSteamAccount)) { Debug.Log("Set a LogOnAnonymous"); SteamGameServer.LogOnAnonymous(); } else { Debug.Log("Set a Logon"); SteamGameServer.LogOn(SteamDSConfig.ServerSteamAccount); } SteamGameServer.EnableHeartbeats(true); SteamDSConfig.initialized = true; } else { Debug.LogError("GameServer.InitSafe failed"); CoopDedicatedServerStarter.ShutDown(); } }
public override void SetServerName(string name) { SteamGameServer.SetServerName(name); }
public void OnServerLoad() { if (Configuration.Instance.Enabled) { if (Configuration.Instance.ResetToDefault) { SteamGameServer.SetKeyValue("rocketplugins", string.Join(",", R.Plugins.GetPlugins().Select(p => p.Name).ToArray())); } else { if (Configuration.Instance.HideRocketPlugins) { SteamGameServer.SetKeyValue("rocketplugins", ""); Logger.Log("SS - Hidden Rocket Plugins! :^) "); } if (Configuration.Instance.ReplaceRocketPlugins) { SteamGameServer.SetKeyValue("rocketplugins", Configuration.Instance.CustomRocketPluginsText); Logger.Log("SS - Replaced Rocket Plugins Text! :^) "); } if (Configuration.Instance.HideWorkshopItems) { SteamGameServer.SetKeyValue("Browser_Workshop_Count", "0"); Logger.Log("SS - Hidden Workshop Items! :^) "); } if (Configuration.Instance.ReplaceWorkshopItems) { SteamGameServer.SetKeyValue("Browser_Workshop_Count", Configuration.Instance.WorkshopLinesCount.ToString()); SteamGameServer.SetKeyValue("Browser_Workshop_Line", Configuration.Instance.CustomWorkshopItemsText); Logger.Log("SS - Replaced Workshop Items Text! :^) "); } if (Configuration.Instance.HideConfigItems) { SteamGameServer.SetKeyValue("Browser_Config_Count", "0"); Logger.Log("SS - Hidden Config Items! :^) "); } if (Configuration.Instance.ReplaceConfigItems) { SteamGameServer.SetKeyValue("Browser_Config_Count", Configuration.Instance.ConfigLinesCount.ToString()); SteamGameServer.SetKeyValue("Browser_Config_Line", Configuration.Instance.CustomConfigItemsText); Logger.Log("SS - Replace Config Items Text! :^) "); } if (Configuration.Instance.EnableCustomMapName) { SteamGameServer.SetMapName(Configuration.Instance.MapCustomName); Logger.Log("SS - Set Map Name to (" + Configuration.Instance.MapCustomName + ") ! :^) "); } if (Configuration.Instance.EnableMaxPlayers) { SteamGameServer.SetMaxPlayerCount(Configuration.Instance.MaxServerPlayers); Logger.Log("SS - Set Max players count to (" + Configuration.Instance.MaxServerPlayers + ") ! :^) "); } if (Configuration.Instance.EnableCustomServerName) { SteamGameServer.SetServerName(Configuration.Instance.ServerName); Logger.Log("SS - Set Server Name to (" + Configuration.Instance.ServerName + ") ! :^) "); } Logger.Log("SS - Done!"); } } else { Logger.Log("SS - Please Enable me in the Configuration in order for me to work :D!"); Unload(); } }