コード例 #1
0
    //-----------------------------------------------------------------------------
    // 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" );
    }
コード例 #2
0
        internal void Initialize()
        {
            try
            {
                Settings    = new XMLFileAsset <UnturnedSettings>(Environment.SettingsFile);
                Translation = new XMLFileAsset <TranslationList>(String.Format(Environment.TranslationFile, Core.R.Settings.Instance.LanguageCode), new Type[] { typeof(TranslationList), typeof(TranslationListEntry) }, defaultTranslations);
                defaultTranslations.AddUnknownEntries(Translation);
                Events = gameObject.TryAddComponent <UnturnedEvents>();

                gameObject.TryAddComponent <UnturnedPermissions>();
                gameObject.TryAddComponent <UnturnedChat>();
                gameObject.TryAddComponent <UnturnedCommands>();

                gameObject.TryAddComponent <AutomaticSaveWatchdog>();

                bindDelegates();

                RocketPlugin.OnPluginLoading += (IRocketPlugin plugin, ref bool cancelLoading) =>
                {
                    try
                    {
                        plugin.TryAddComponent <PluginUnturnedPlayerComponentManager>();
                    }
                    catch (Exception ex)
                    {
                        Core.Logging.Logger.LogException(ex, "Failed to load plugin " + plugin.Name + ".");
                        cancelLoading = true;
                    }
                };

                RocketPlugin.OnPluginUnloading += (IRocketPlugin plugin) =>
                {
                    plugin.TryRemoveComponent <PluginUnturnedPlayerComponentManager>();
                };

                R.Commands.RegisterFromAssembly(Assembly.GetExecutingAssembly());

                try
                {
                    R.Plugins.OnPluginsLoaded += () =>
                    {
                        SteamGameServer.SetKeyValue("rocketplugins", String.Join(",", R.Plugins.GetPlugins().Select(p => p.Name).ToArray()));
                    };


                    SteamGameServer.SetKeyValue("rocket", Assembly.GetExecutingAssembly().GetName().Version.ToString());
                    SteamGameServer.SetBotPlayerCount(1);
                }
                catch (Exception ex)
                {
                    Core.Logging.Logger.LogError("Steam can not be initialized: " + ex.Message);
                }

                OnRocketImplementationInitialized.TryInvoke();
            }
            catch (Exception ex)
            {
                Core.Logging.Logger.LogException(ex);
            }
        }
コード例 #3
0
 private void SendUpdatedServerDetailsToSteam()
 {
     SteamGameServer.SetMaxPlayerCount(SteamDSConfig.ServerPlayers);
     SteamGameServer.SetPasswordProtected(false);
     SteamGameServer.SetServerName(SteamDSConfig.ServerName);
     SteamGameServer.SetBotPlayerCount(0);
     SteamGameServer.SetMapName(SteamDSConfig.MapName);
 }
コード例 #4
0
 private void OnSteamServersConnected(SteamServersConnected_t LogonSuccess)
 {
     _connectedToSteam = true;
     SteamGameServer.SetMaxPlayerCount(4);
     SteamGameServer.SetPasswordProtected(false);
     SteamGameServer.SetServerName("Snakes");
     SteamGameServer.SetBotPlayerCount(0);
     SteamGameServer.SetMapName("inGame");
 }
コード例 #5
0
    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
    }
コード例 #6
0
        private void EditLobby()
        {
            string mode;
            string perspective;
            string thumbnail;
            bool   workshop = Provider.getServerWorkshopFileIDs().Count > 0;

            #region Plugins
            if (m_Configuration.GetSection("Hide:Rocket").Get <bool>())
            {
                SteamGameServer.SetBotPlayerCount(0);
            }

            if (!m_Configuration.GetSection("Hide:Plugins").Get <bool>())
            {
                if (m_Configuration.GetSection("Edit:Plugins").Get <bool>())
                {
                    SteamGameServer.SetKeyValue("rocketplugins", string.Join(",", m_Configuration.GetSection("PluginsOverride").Get <string[]>()));
                }
                else
                {
                    SteamGameServer.SetKeyValue("rocketplugins", string.Join(",", m_PluginActivator.ActivatedPlugins.ToList().Select(p => p.DisplayName).ToArray()));
                }
            }
            else
            {
                SteamGameServer.SetKeyValue("rocketplugins", "");
            }

            if (m_Configuration.GetSection("GameTags:Vanilla").Get <bool>())
            {
                SteamGameServer.SetBotPlayerCount(0);
                SteamGameServer.SetKeyValue("rocketplugins", "");
                SteamGameServer.SetKeyValue("rocket", "");
            }
            else
            {
                if (!m_Configuration.GetSection("Hide:Rocket").Get <bool>())
                {
                    SteamGameServer.SetBotPlayerCount(1);
                }

                if (!m_Configuration.GetSection("Hide:Plugins").Get <bool>() && !m_Configuration.GetSection("Edit:Plugins").Get <bool>())
                {
                    SteamGameServer.SetKeyValue("rocketplugins", string.Join(",", m_PluginActivator.ActivatedPlugins.ToList().Select(p => p.DisplayName).ToArray()));
                }

                string version = ModuleHook.modules.Find(a => a.config.Name == "Rocket.Unturned")?.config.Version ?? "4.9.3.3";
                SteamGameServer.SetKeyValue("rocket", version);
            }
            #endregion

            #region Workshops

            /*if (Configuration.Instance.HideWorkshop)
             * {
             *  workshop = false;
             *  SteamGameServer.SetKeyValue("Browser_Workshop_Count", "0");
             * }
             * else if (Configuration.Instance.EditWorkshop)
             * {
             *  workshop = true;
             *  string txt = string.Join(",", Configuration.Instance.Workshop);
             *  SteamGameServer.SetKeyValue("Browser_Workshop_Count", ((txt.Length - 1) / 120 + 1).ToString());
             *
             *  int line = 0;
             *  for (int i = 0; i < txt.Length; i += 120)
             *  {
             *      int num6 = 120;
             *
             *      if (i + num6 > txt.Length)
             *          num6 = txt.Length - i;
             *
             *      string pValue2 = txt.Substring(i, num6);
             *      SteamGameServer.SetKeyValue("Browser_Workshop_Line_" + line, pValue2);
             *      line++;
             *  }
             * }
             * else
             * {
             *  SteamGameServer.SetKeyValue("Browser_Workshop_Count", GetWorkshopCount().ToString());
             * }*/
            #endregion

            #region Configs
            if (m_Configuration.GetSection("Hide:Config").Get <bool>())
            {
                SteamGameServer.SetKeyValue("Browser_Config_Count", "0");
            }
            else
            {
                SteamGameServer.SetKeyValue("Browser_Config_Count", GetConfigurationCount().ToString());
            }

            switch (m_Configuration["GameTags:Mode"].ToLower().Trim())
            {
            case "easy":
                mode = "EZY";
                break;

            case "hard":
                mode = "HRD";
                break;

            default:
                mode = "NRM";
                break;
            }

            switch (m_Configuration["GameTags:Perspective"].ToLower().Trim())
            {
            case "first":
                perspective = "1Pp";
                break;

            case "third":
                perspective = "3Pp";
                break;

            case "vehicle":
                perspective = "4Pp";
                break;

            default:
                perspective = "2Pp";
                break;
            }
            #endregion

            #region Thumbnail
            if (!m_Configuration.GetSection("Hide:Thumbnail").Get <bool>())
            {
                switch (m_Configuration.GetSection("Edit:Thumbnail").Get <bool>())
                {
                case true:
                    thumbnail = m_Configuration["ThumbnailOverride"];
                    break;

                case false:
                    thumbnail = Provider.configData.Browser.Thumbnail;
                    break;

                default:
                    thumbnail = Provider.configData.Browser.Thumbnail;
                    break;
                }
            }
            else
            {
                thumbnail = "";
            }
            #endregion

            #region GameTags
            string tags = string.Concat(new string[]
            {
                m_Configuration.GetSection("GameTags:PVP").Get <bool>() ? "PVP" : "PVE",
                ",<gm>",
                m_Configuration["GameTags:GameMode"],
                "</gm>,",
                m_Configuration.GetSection("GameTags:Cheats").Get <bool>() ? "CHy" : "CHn",
                ",",
                mode,
                ",",
                perspective,
                ",",
                workshop ? "WSy" : "WSn",
                ",", m_Configuration.GetSection("GameTags:Gold").Get <bool>() ? "GLD" : "F2P",
                ",", m_Configuration.GetSection("GameTags:BattlEyeSecure").Get <bool>() ? "BEy" : "BEn",
                ",<tn>", thumbnail, "</tn>"
            });
            SteamGameServer.SetGameTags(tags);
            #endregion
        }
コード例 #7
0
        public void ModifyGameTags()
        {
            string tags = "";

            #region Workshop
            if (Configuration.Instance.HideWorkshop)
            {
                tags += "KROW"; // No workshop
                SteamGameServer.SetKeyValue("Browser_Workshop_Count", "0");
            }
            else if (Configuration.Instance.MessWorkshop)
            {
                tags += "WORK"; // Workshop

                string txt = "";
                foreach (string a in Configuration.Instance.Workshop)
                {
                    if (txt.Length > 0)
                    {
                        txt += ",";
                    }
                    txt += a;
                }
                SteamGameServer.SetKeyValue("Browser_Workshop_Count", ((txt.Length - 1) / 120 + 1).ToString());

                int num5 = 0;
                for (int m = 0; m < txt.Length; m += 120)
                {
                    int num6 = 120;
                    if (m + num6 > txt.Length)
                    {
                        num6 = txt.Length - m;
                    }
                    string pValue2 = txt.Substring(m, num6);
                    SteamGameServer.SetKeyValue("Browser_Workshop_Line_" + num5, pValue2);
                    num5++;
                }
            }
            else
            {
                if (Provider.serverWorkshopFileIDs.Count <= 0)
                {
                    tags += "KROW";
                }
                else
                {
                    tags += "WORK"; // Workshop
                    SteamGameServer.SetKeyValue("Browser_Workshop_Count", GetWorkshopCount().ToString());
                }
            }
            #endregion

            #region Gamemode
            if (Configuration.Instance.MessGamemode)
            {
                tags += ",GAMEMODE:" + Configuration.Instance.Gamemode;
            }
            else if (Provider.gameMode != null)
            {
                tags += ",GAMEMODE:" + Provider.gameMode.GetType().Name;
            }
            #endregion

            #region Config
            if (Configuration.Instance.MessConfig)
            {
                tags += ",";
                if (Configuration.Instance.IsPVP)
                {
                    tags += "PVP";
                }
                else
                {
                    tags += "PVE";
                }
                tags += ",";
                if (Configuration.Instance.HasCheats)
                {
                    tags += "CHEATS";
                }
                else
                {
                    tags += "STAEHC";
                }
                tags += ",";
                tags += Configuration.Instance.Difficulty;
                tags += ",";
                tags += Configuration.Instance.CameraMode;
                tags += ",";
                if (Configuration.Instance.GoldOnly)
                {
                    tags += "GOLDONLY";
                }
                else
                {
                    tags += "YLNODLOG";
                }
                tags += ",";
                if (Configuration.Instance.HasBattleye)
                {
                    tags += "BATTLEYE_ON";
                }
                else
                {
                    tags += "BATTLEYE_OFF";
                }
            }
            else
            {
                tags += ",";
                tags += (!Provider.isPvP) ? "PVE" : "PVP";
                tags += ",";
                tags += (!Provider.hasCheats) ? "STAEHC" : "CHEATS";
                tags += ",";
                tags += Provider.mode.ToString();
                tags += ",";
                tags += Provider.cameraMode.ToString();
                tags += ",";
                tags += (!Provider.isGold) ? "YLNODLOG" : "GOLDONLY";
                tags += ",";
                tags += (!Provider.configData.Server.BattlEye_Secure) ? "BATTLEYE_OFF" : "BATTLEYE_ON";
            }
            #endregion

            #region Configuration
            if (Configuration.Instance.HideConfig)
            {
                SteamGameServer.SetKeyValue("Browser_Config_Count", "0");
            }
            else
            {
                SteamGameServer.SetKeyValue("Browser_Config_Count", GetConfigurationCount().ToString());
            }
            #endregion

            SteamGameServer.SetGameTags(tags);

            #region Plugins
            if (Configuration.Instance.InvisibleRocket)
            {
                SteamGameServer.SetBotPlayerCount(0); // Bypasses unturned's filter for rocket <3
            }
            if (!Configuration.Instance.HidePlugins)
            {
                if (Configuration.Instance.MessPlugins)
                {
                    SteamGameServer.SetKeyValue("rocketplugins", string.Join(",", Configuration.Instance.Plugins));
                }
                else
                {
                    SteamGameServer.SetKeyValue("rocketplugins", string.Join(",", R.Plugins.GetPlugins().Select(p => p.Name).ToArray()));
                }
            }
            else
            {
                SteamGameServer.SetKeyValue("rocketplugins", "");
            }

            if (Configuration.Instance.IsVannila)
            {
                SteamGameServer.SetBotPlayerCount(0);
                SteamGameServer.SetKeyValue("rocketplugins", "");
                SteamGameServer.SetKeyValue("rocket", "");
            }
            else
            {
                if (!Configuration.Instance.InvisibleRocket)
                {
                    SteamGameServer.SetBotPlayerCount(1);
                }
                if (!Configuration.Instance.HidePlugins && !Configuration.Instance.MessPlugins)
                {
                    SteamGameServer.SetKeyValue("rocketplugins", string.Join(",", R.Plugins.GetPlugins().Select(p => p.Name).ToArray()));
                }
                SteamGameServer.SetKeyValue("rocket", ModuleHook.modules.FirstOrDefault(a => a.config.Name == "Rocket.Unturned").config.Version);
            }
            #endregion
        }
コード例 #8
0
        internal void Initialize()
        {
            try
            {
                Settings    = new XMLFileAsset <UnturnedSettings>(Environment.SettingsFile);
                Translation = new XMLFileAsset <TranslationList>(string.Format(Environment.TranslationFile, Core.R.Settings.Instance.LanguageCode), new Type[] { typeof(TranslationList), typeof(TranslationListEntry) }, defaultTranslations);
                defaultTranslations.AddUnknownEntries(Translation);
                //Events = gameObject.TryAddComponent<UnturnedEvents>();
                Events = new UnturnedEvents();
                Events.Awake();
                //gameObject.TryAddComponent<UnturnedPermissions>();
                //gameObject.TryAddComponent<UnturnedChat>();
                SDG.Unturned.ChatManager.onChatted += UnturnedChat.handleChat;
                //gameObject.TryAddComponent<UnturnedCommands>();
                foreach (Command vanillaCommand in Commander.commands)
                {
                    R.Commands.Register(new UnturnedCommands.UnturnedVanillaCommand(vanillaCommand), vanillaCommand.command.ToLower(), Core.Serialization.CommandPriority.Low);
                }
                gameObject.TryAddComponent <AutomaticSaveWatchdog>();

                bindDelegates();

                RocketPlugin.OnPluginLoading += (IRocketPlugin plugin, ref bool cancelLoading) =>
                {
                    try
                    {
                        plugin.TryAddComponent <PluginUnturnedPlayerComponentManager>();
                    }
                    catch (Exception ex)
                    {
                        Core.Logging.Logger.LogException(ex, "Failed to load plugin " + plugin.Name + ".");
                        cancelLoading = true;
                    }
                };

                RocketPlugin.OnPluginUnloading += (IRocketPlugin plugin) =>
                {
                    plugin.TryRemoveComponent <PluginUnturnedPlayerComponentManager>();
                };

                R.Commands.RegisterFromAssembly(Assembly.GetExecutingAssembly());

                try
                {
                    if (!Settings.Instance.HidePlugins)
                    {
                        R.Plugins.OnPluginsLoaded += () =>
                        {
                            var plugs = R.Plugins.GetPlugins();
                            var names = new string[plugs.Count];
                            for (int i = 0; i < names.Length; i++)
                            {
                                names[i] = plugs[i].Name;
                            }
                            SteamGameServer.SetKeyValue("rocketplugins", string.Join(",", names));
                        };
                    }
                    if (Settings.Instance.ClampMaxPlayers)
                    {
                        Level.onPreLevelLoaded += ClampMaxPlayers;
                    }

                    SteamGameServer.SetKeyValue("unturned", Provider.APP_VERSION);
                    SteamGameServer.SetKeyValue("rocket", Assembly.GetExecutingAssembly().GetName().Version.ToString());
                    SteamGameServer.SetBotPlayerCount(1);
                }
                catch (Exception ex)
                {
                    Core.Logging.Logger.LogError("Steam can not be initialized: " + ex.Message);
                }

                OnRocketImplementationInitialized.TryInvoke();
            }
            catch (Exception ex)
            {
                Core.Logging.Logger.LogException(ex);
            }
        }