Exemplo n.º 1
0
        private void m_prcClient_ProconAdminSaying(PRoConClient sender, string strAdminStack, string strMessage, CPlayerSubset spsAudience)
        {
            string strAdminName     = Client.Language.GetLocalized("uscChatPanel.rtbChatBox.Admin", null);
            string formattedMessage = String.Empty;

            if (strAdminStack.Length > 0)
            {
                strAdminName = String.Join(" via ", CPluginVariable.DecodeStringArray(strAdminStack));
            }

            if (spsAudience.Subset == CPlayerSubset.PlayerSubsetType.All)
            {
                formattedMessage = String.Format("^b^2{0}^0 > ^2{1}", strAdminName, strMessage);
            }
            else if (spsAudience.Subset == CPlayerSubset.PlayerSubsetType.Player)
            {
                formattedMessage = String.Format("^b^2{0}^0 -^2 {1}^0 > ^2{2}", strAdminName, spsAudience.SoldierName, strMessage);
            }
            else if (spsAudience.Subset == CPlayerSubset.PlayerSubsetType.Team)
            {
                formattedMessage = String.Format("^b^2{0}^0 -^2 {1}^0 >^2 {2}", strAdminName, Client.GetLocalizedTeamName(spsAudience.TeamID, Client.CurrentServerInfo.Map, Client.CurrentServerInfo.GameMode), strMessage);
            }
            else if (spsAudience.Subset == CPlayerSubset.PlayerSubsetType.Squad)
            {
                formattedMessage = String.Format("^b^2{0}^0 -^2 {1}^0 - ^2{2}^0 >^2 {3}", strAdminName, Client.GetLocalizedTeamName(spsAudience.TeamID, Client.CurrentServerInfo.Map, Client.CurrentServerInfo.GameMode), Client.Language.GetLocalized("global.Squad" + spsAudience.SquadID.ToString(CultureInfo.InvariantCulture), null), strMessage);
            }

            if (formattedMessage.Length > 0)
            {
                EnqueueMessage(new ChatMessage(DateTime.UtcNow.ToUniversalTime().AddHours(Client.Game.UtcOffset).ToLocalTime(), strAdminName, strMessage, true, false, spsAudience));
                Write(DateTime.UtcNow.ToUniversalTime().AddHours(Client.Game.UtcOffset).ToLocalTime(), formattedMessage);
            }
        }
Exemplo n.º 2
0
        public void SetPluginVariable(string strVariable, string strValue)
        {
            int intOut = 0;
            int a      = strVariable.IndexOf("|");
            int b      = strVariable.IndexOf(".");
            int c      = b - a;

            if (strVariable.CompareTo("Number of Triggers") == 0 && int.TryParse(strValue, out intOut) == true)
            {
                this.t_numberOfRules = intOut;
            }

            if (c > 0)
            {
                int.TryParse(strVariable.Substring(strVariable.IndexOf("|") + 1, (strVariable.IndexOf(".") - strVariable.IndexOf("|") - 1)), out intOut);
                Rule rule = t_dicRules[intOut];

                if (strVariable.CompareTo(string.Format("{0}.1 Chat trigger:", rule.ID)) == 0)
                {
                    rule.Trigger = strValue;
                }
                else if (strVariable.CompareTo(string.Format("{0}.2 Yell output?", rule.ID)) == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
                {
                    rule.Yell = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
                }
                else if (strVariable.CompareTo(string.Format("{0}.3 Send to all?", rule.ID)) == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
                {
                    rule.SendToAll = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
                }
                else if (strVariable.CompareTo(string.Format("{0}.4 Delay before sending output:", rule.ID)) == 0)
                {
                    rule.DelaySend = int.Parse(strValue);
                }
                else if (strVariable.CompareTo(string.Format("{0}.5 How long to show yelled output:", rule.ID)) == 0)
                {
                    rule.DisplayTime = int.Parse(strValue);
                }
                else if (strVariable.CompareTo(string.Format("{0}.6 Delay between each line of output:", rule.ID)) == 0)
                {
                    rule.DelayBetween = int.Parse(strValue);
                }
                else if (strVariable.CompareTo(string.Format("{0}.7 Output text:", rule.ID)) == 0)
                {
                    rule.Output = CPluginVariable.DecodeStringArray(strValue);
                }
            }
        }
Exemplo n.º 3
0
        private void SendTaskPlanerInfo()
        {
            Variables.Add("Enable Spectators Player Count");
            Variables.Add("Disable Spectators Player Count");
            Variables.Add("Spectator Ports Count");



            PluginInfo["PluginName"]      = GetPluginName();
            PluginInfo["PluginVersion"]   = GetPluginVersion();
            PluginInfo["PluginClassname"] = GetCurrentClassName();

            PluginInfo["PluginCommands"]  = CPluginVariable.EncodeStringArray(Commands.ToArray());
            PluginInfo["PluginVariables"] = CPluginVariable.EncodeStringArray(Variables.ToArray());

            this.ExecuteCommand("procon.protected.plugins.setVariable", "ExtraTaskPlaner", "RegisterPlugin", JSON.JsonEncode(PluginInfo)); // Send Plugin Infos to Task Planer
        }
Exemplo n.º 4
0
        private void ppgScriptSettings_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            if (this.m_cscPluginVariables.ContainsKey(e.ChangedItem.Label) == true)
            {
                string strValue = e.ChangedItem.Value.ToString();

                if (this.m_cscPluginVariables[e.ChangedItem.Label].Type == typeof(bool))
                {
                    strValue = strValue.ToLower();
                }
                //               else if (this.m_cscPluginVariables[e.ChangedItem.Label].Type == typeof(string)) {
                //                   strValue = strValue;
                //               }
                else if (this.m_cscPluginVariables[e.ChangedItem.Label].Type == typeof(string[]))
                {
                    strValue = CPluginVariable.EncodeStringArray((string[])e.ChangedItem.Value);
                }

                // TO DO: Set the script variable.
                //this.m_frmMainParent.SetSingleSv(this.m_cscPluginVariables[e.ChangedItem.Label].ClassName, e.ChangedItem.Label, strValue);

                this.SetPluginVariable(this.m_cscPluginVariables[e.ChangedItem.Label].ClassName, e.ChangedItem.Label, strValue);

                //this.lsvLoadedPlugins_SelectedIndexChanged(this, null);
                this.RefreshSelectedPlugin();

                if (this.m_cscPluginVariables.ContainsKey(e.ChangedItem.Label) == true)
                {
                    PluginDetails spdUpdatedDetails = this.GetPluginDetails(this.m_cscPluginVariables[e.ChangedItem.Label].ClassName);
                    if (this.PluginVariablesAltered != null)
                    {
                        this.PluginVariablesAltered(spdUpdatedDetails);
                    }
                }

                //foreach (KeyValuePair<string, CPRoConLayerClient> kvpConnection in this.m_dicLayerClients) {
                //    kvpConnection.Value.OnPluginVariablesAltered(spdUpdatedDetails);
                //}
            }
        }
Exemplo n.º 5
0
 public void SetPluginVariable(string strVariable, string strValue)
 {
     if (strVariable.CompareTo("API Key") == 0)
     {
         this.bf4db_APIKey = strValue;
     }
     if (strVariable.CompareTo("Enable Auto Bans") == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
     {
         this.bf4db_EnableAutoBan = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
     }
     if (strVariable.CompareTo("Enable Cheat Announcements") == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
     {
         this.bf4db_EnableAnnouncements = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
     }
     if (strVariable.CompareTo("Enable Clean Announcements") == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
     {
         this.bf4db_EnableCleanAnnouncements = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
     }
     if (strVariable.CompareTo("Enable Whitelist Announcements") == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
     {
         this.bf4db_EnableVerifiedAnnouncements = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
     }
     if (strVariable.CompareTo("Whitelist") == 0)
     {
         this.bf4db_whitelist = new List <string>(CPluginVariable.DecodeStringArray(strValue));
     }
     if (strVariable.CompareTo("Check Command(/!#@)") == 0)
     {
         this.bf4db_CheckCommand = strValue;
     }
     if (strVariable.CompareTo("Debug Level") == 0)
     {
         int tmp = 1;
         int.TryParse(strValue, out tmp);
         this.bf4db_DebugLevel = tmp;
     }
 }
Exemplo n.º 6
0
        public void SetPluginVariable(string strVariable, string strValue)
        {
            int iTimeSeconds = 15;

            if (strVariable.CompareTo("Maplist") == 0)
            {
                this.m_lstMapDefines = this.GetMapDefines();
                List <string> lstValidateMaplist = new List <string>(CPluginVariable.DecodeStringArray(strValue));

                // Gets rid of the error message when no array is set.
                lstValidateMaplist.RemoveAll(String.IsNullOrEmpty);

                if (this.m_lstMaplist.Count > 0)
                {
                    this.ExecuteCommand("procon.protected.pluginconsole.write", String.Format("^b^3Clearing Maplist.."));
                    this.m_lstMaplist.Clear();
                }

                string strPreviouslyAddedMapFilename = "";
                bool   blShowMapAdditionError        = true;
                foreach (string strMapFileNameRound in lstValidateMaplist)
                {
                    string[] a_strMapFileNameRound = strMapFileNameRound.Split(' ');

                    string strMapFileName = "";
                    int    iRounds        = 0;

                    if (a_strMapFileNameRound.Length >= 1)
                    {
                        strMapFileName = a_strMapFileNameRound[0];

                        if (a_strMapFileNameRound.Length >= 2)
                        {
                            int.TryParse(a_strMapFileNameRound[1], out iRounds);
                        }
                    }

                    if (String.IsNullOrEmpty(strMapFileName) == false)
                    {
                        blShowMapAdditionError = true;

                        foreach (CMap cMapDefine in this.m_lstMapDefines)
                        {
                            if (String.Compare(strMapFileName, cMapDefine.FileName, true) == 0)
                            {
                                if (String.Compare(strPreviouslyAddedMapFilename, cMapDefine.FileName, true) != 0)
                                {
                                    this.m_lstMaplist.Add(new CMapNameRounds(cMapDefine.FileName.ToLower(), iRounds));
                                    strPreviouslyAddedMapFilename = cMapDefine.FileName;

                                    if (iRounds == 0)
                                    {
                                        this.ExecuteCommand("procon.protected.pluginconsole.write", String.Format("^b^2Adding ^4{0} ^5{1}^2 to the rotation with default number of rounds..", cMapDefine.GameMode, cMapDefine.PublicLevelName));
                                    }
                                    else
                                    {
                                        this.ExecuteCommand("procon.protected.pluginconsole.write", String.Format("^b^2Adding ^4{0} ^5{1}^2 to the rotation with {2} round(s)..", cMapDefine.GameMode, cMapDefine.PublicLevelName, iRounds));
                                    }
                                }
                                else
                                {
                                    this.ExecuteCommand("procon.protected.pluginconsole.write", String.Format("^b^1Removing consecutive map \"{0}\" from the list.  Can't run the same map twice in a row =(", strMapFileName));
                                }

                                blShowMapAdditionError = false;
                                break;
                            }
                        }

                        if (blShowMapAdditionError == true)
                        {
                            this.ExecuteCommand("procon.protected.pluginconsole.write", String.Format("^b^1The map \"{0}\" is not a valid map (or it's unknown to procon at the moment)", strMapFileName));
                        }
                    }
                }

                if (this.m_iCurrentIndex > this.m_lstMaplist.Count)
                {
                    this.m_iCurrentIndex = 0;
                }
            }
        }
Exemplo n.º 7
0
        private void SetPluginsVariables(string strClassName, string strPluginName, List <CPluginVariable> lstVariables)
        {
            if (lstVariables != null)
            {
                foreach (CPluginVariable cpvVariable in lstVariables)
                {
                    string strCategoryName = strPluginName;
                    string strVariableName = cpvVariable.Name;

                    string[] a_strVariable = cpvVariable.Name.Split(new char[] { '|' }, 2);
                    if (a_strVariable.Length == 2)
                    {
                        strCategoryName = a_strVariable[0];
                        strVariableName = a_strVariable[1];
                    }

                    Enum  generatedEnum = null;
                    Match isGeneratedEnum;
                    if ((isGeneratedEnum = Regex.Match(cpvVariable.Type, @"enum.(?<enumname>.*?)\((?<literals>.*)\)")).Success == true)
                    {
                        if ((generatedEnum = this.GenerateEnum(isGeneratedEnum.Groups["enumname"].Value, isGeneratedEnum.Groups["literals"].Value.Split('|'))) != null)
                        {
                            string variableValue = cpvVariable.Value;

                            if (Enum.IsDefined(generatedEnum.GetType(), variableValue) == false)
                            {
                                string[] a_Names = Enum.GetNames(generatedEnum.GetType());

                                if (a_Names.Length > 0)
                                {
                                    variableValue = a_Names[0];
                                }
                            }

                            if (Enum.IsDefined(generatedEnum.GetType(), variableValue) == true)
                            {
                                if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false)
                                {
                                    this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, Enum.Parse(generatedEnum.GetType(), variableValue), generatedEnum.GetType(), false, true));
                                }
                                else
                                {
                                    this.m_cscPluginVariables[cpvVariable.Name].Value = Enum.Parse(generatedEnum.GetType(), variableValue);
                                }
                            }
                        }
                    }
                    else
                    {
                        switch (cpvVariable.Type)
                        {
                        case "bool":
                            bool blTryBool;
                            if (bool.TryParse(cpvVariable.Value, out blTryBool) == true)
                            {
                                if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false)
                                {
                                    this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, blTryBool, typeof(bool), false, true));
                                }
                                else
                                {
                                    this.m_cscPluginVariables[cpvVariable.Name].Value = blTryBool;
                                }
                            }
                            break;

                        case "onoff":
                            if (Enum.IsDefined(typeof(enumBoolOnOff), cpvVariable.Value) == true)
                            {
                                if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false)
                                {
                                    this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, Enum.Parse(typeof(enumBoolOnOff), cpvVariable.Value), typeof(enumBoolOnOff), false, true));
                                }
                                else
                                {
                                    this.m_cscPluginVariables[cpvVariable.Name].Value = Enum.Parse(typeof(enumBoolOnOff), cpvVariable.Value);
                                }
                            }
                            break;

                        case "yesno":
                            if (Enum.IsDefined(typeof(enumBoolYesNo), cpvVariable.Value) == true)
                            {
                                if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false)
                                {
                                    this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, Enum.Parse(typeof(enumBoolYesNo), cpvVariable.Value), typeof(enumBoolYesNo), false, true));
                                }
                                else
                                {
                                    this.m_cscPluginVariables[cpvVariable.Name].Value = Enum.Parse(typeof(enumBoolYesNo), cpvVariable.Value);
                                }
                            }
                            break;

                        case "int":
                            int iTryInt;
                            if (int.TryParse(cpvVariable.Value, out iTryInt) == true)
                            {
                                if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false)
                                {
                                    this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, iTryInt, typeof(int), false, true));
                                }
                                else
                                {
                                    this.m_cscPluginVariables[cpvVariable.Name].Value = iTryInt;
                                }
                            }
                            break;

                        case "double":
                            double dblTryDouble;
                            if (double.TryParse(cpvVariable.Value, out dblTryDouble) == true)
                            {
                                if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false)
                                {
                                    this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, dblTryDouble, typeof(double), false, true));
                                }
                                else
                                {
                                    this.m_cscPluginVariables[cpvVariable.Name].Value = dblTryDouble;
                                }
                            }
                            break;

                        case "string":
                            if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false)
                            {
                                this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, CPluginVariable.Decode(cpvVariable.Value), typeof(String), false, true));
                            }
                            else
                            {
                                this.m_cscPluginVariables[cpvVariable.Name].Value = cpvVariable.Value;
                            }
                            break;

                        case "multiline":
                            if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false)
                            {
                                CustomProperty cptNewProperty = new CustomProperty(strVariableName, strCategoryName, strClassName, CPluginVariable.Decode(cpvVariable.Value), typeof(String), false, true);

                                cptNewProperty.Attributes = new AttributeCollection(new EditorAttribute(typeof(System.ComponentModel.Design.MultilineStringEditor), typeof(System.Drawing.Design.UITypeEditor)), new TypeConverterAttribute(typeof(System.ComponentModel.Design.MultilineStringEditor)));
                                this.m_cscPluginVariables.Add(cptNewProperty);
                            }
                            else
                            {
                                this.m_cscPluginVariables[cpvVariable.Name].Value = cpvVariable.Value;
                            }
                            break;

                        case "stringarray":
                            if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false)
                            {
                                this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, CPluginVariable.DecodeStringArray(cpvVariable.Value), typeof(string[]), false, true));

                                //this.m_cscPluginVariables.Add(new CustomProperty(cpvVariable.Name, strPluginName, strClassName, "Alaska", typeof(StatesList), false, true));
                            }
                            else
                            {
                                this.m_cscPluginVariables[cpvVariable.Name].Value = CPluginVariable.DecodeStringArray(cpvVariable.Value);
                            }

                            break;
                        }
                        //                }
                    }
                }
            }

            this.ppgScriptSettings.Refresh();
        }
Exemplo n.º 8
0
        // Allways be suspicious of strValue's actual value.  A command in the console can
        // by the user can put any kind of data it wants in strValue.
        // use type.TryParse
        public void SetPluginVariable(string strVariable, string strValue)
        {
            int iTmp;

            this.UnregisterAllCommands();

            if (strVariable.CompareTo("Ping Interval") == 0)
            {
                if (int.TryParse(strValue, out iTmp) && iTmp > 0)
                {
                    this.strPingInterval = strValue;
                    this.ExecuteCommand("procon.protected.tasks.remove", "CPingPlayersWorker");
                    this.ExecuteCommand("procon.protected.tasks.add", "CPingPlayersWorker", "5", this.strPingInterval, "-1", "procon.protected.plugins.call", "CPingPlayers", "PingAllPlayers");
                }
            }
            else if (strVariable.CompareTo("Max. Ping") == 0)
            {
                if (int.TryParse(strValue, out iTmp) && iTmp > 0)
                {
                    this.iMaxPing = iTmp;
                }
            }
            else if (strVariable.CompareTo("Grace Period") == 0)
            {
                if (int.TryParse(strValue, out iTmp) && iTmp > 0)
                {
                    this.iGracePeriod = iTmp;
                }
            }
            else if (strVariable.CompareTo("Ping Timeout") == 0)
            {
                if (int.TryParse(strValue, out iTmp) && iTmp > 0)
                {
                    this.iPingTimeout = iTmp;
                }
            }
            else if (strVariable.CompareTo("Kick Reason") == 0)
            {
                this.strKickReason = strValue;
            }
            else if (strVariable.CompareTo("White List") == 0)
            {
                this.lstWhiteList = new List <string>(CPluginVariable.DecodeStringArray(strValue));
            }
            else if (strVariable.CompareTo("Ingame Warnings") == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
            {
                this.ebIngameWarnings = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
            }
            else if (strVariable.CompareTo("Debug Messages") == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
            {
                this.ebDebugMessages = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
            }
            else if (strVariable.CompareTo("Ingame Command Own Ping") == 0)
            {
                this.strIngameCommandOwn = strValue;
            }
            else if (strVariable.CompareTo("Ingame Command Other Player's Ping") == 0)
            {
                this.strIngameCommandPlayer = strValue;
            }
            else if (strVariable.CompareTo("Ping-Reply Storage Length") == 0)
            {
                if (int.TryParse(strValue, out iTmp) && iTmp > 0)
                {
                    this.iPingStorageLength = iTmp;
                }
            }

            this.RegisterAllCommands();
        }
 public static string[] ToArray(this string s)
 {
     return(CPluginVariable.Decode(s)
            .Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries)
            .ToArray());
 }
Exemplo n.º 10
0
        public void SetPluginVariable(string strVariable, string strValue)
        {
            int iValue = 16;

            //COUNTRY VARIABLES
            if (strVariable.CompareTo("Action") == 0)
            {
                this.strSelectType = strValue;
            }
            else if (strVariable.CompareTo("Country list") == 0)
            {
                if (strValue.CompareTo("N/A") != 0)
                {
                    this.lsSelectedCountries.Add(strValue);
                }
            }
            else if (strVariable.CompareTo("Selected countries") == 0)
            {
                this.lsSelectedCountries = new List <string>(CPluginVariable.DecodeStringArray(strValue));
            }
            else if (strVariable.CompareTo("Enable Country based kick?") == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
            {
                this.enableCountryKick = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
            }
            else if (strVariable.CompareTo("Country kick message") == 0)
            {
                this.strCountryKickMessage = strValue;
            }

            // PING VARIABLES
            else if (strVariable.CompareTo("Enable high ping kick?") == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
            {
                this.enablePingKick = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
            }
            else if (strVariable.CompareTo("Ping limit") == 0 && int.TryParse(strValue, out iValue) == true)
            {
                this.intPingLimit = iValue;
            }
            else if (strVariable.CompareTo("High ping kick message") == 0)
            {
                this.strPingKickMessage = strValue;
            }
            else if (strVariable.CompareTo("Ping Kick Method") == 0)
            {
                this.strPingMethod = strValue;
            }
            else if (strVariable.CompareTo("Instant kick no ping?") == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
            {
                this.enableNoPingKick = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
            }
            else if (strVariable.CompareTo("Pings to sample for average") == 0 && int.TryParse(strValue, out iValue) == true)
            {
                if (iValue < this.intAverageMinCount)
                {
                    this.intAverageMinCount = iValue;
                }
                this.intAverageAccuracy = iValue;
            }
            else if (strVariable.CompareTo("Minimum pings before kicking") == 0 && int.TryParse(strValue, out iValue) == true)
            {
                if (iValue > this.intAverageAccuracy)
                {
                    this.intAverageMinCount = this.intAverageAccuracy;
                }
                else
                {
                    this.intAverageMinCount = iValue;
                }
            }

            // GENERAL VARIABLES
            else if (strVariable.CompareTo("Minimum players before rule enforced (0: none)") == 0 && int.TryParse(strValue, out iValue) == true)
            {
                this.intPlayerLimit = iValue;
            }
            else if (strVariable.CompareTo("Whitelist") == 0)
            {
                this.lsWhitelist = new List <string>(CPluginVariable.DecodeStringArray(strValue));
            }
            else if (strVariable.CompareTo("Debug messages?") == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
            {
                this.debugMessages = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
            }
            else if (strVariable.CompareTo("Display plugin update message?") == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
            {
                this.displayVersionMessage = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
                if (this.displayVersionMessage == enumBoolYesNo.No)
                {
                    this.ExecuteCommand("procon.protected.tasks.remove", "VersionTrackerTask");
                }
            }
            else if (strVariable.CompareTo("Yell or Say ingame message") == 0)
            {
                this.strIngameType = strValue;
            }
            else if (strVariable.CompareTo("Ingame messages?") == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
            {
                this.ingameMessage = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
            }
        }
Exemplo n.º 11
0
        public void SetPluginVariable(string strVariable, string strValue)
        {
            int iTimeSeconds = 0;
            int iTmpValue    = 0;

            // Basics
            if (strVariable.CompareTo("Private Prefix") == 0)
            {
                this.m_strPrivatePrefix = strValue;
            }
            else if (strVariable.CompareTo("Admins Prefix") == 0)
            {
                this.m_strAdminsPrefix = strValue;
            }
            else if (strVariable.CompareTo("Public Prefix") == 0)
            {
                this.m_strPublicPrefix = strValue;
            }
            // Welcome
            else if (strVariable.CompareTo("Enable welcome") == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
            {
                this.m_bEnableWelcome = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
            }
            else if (strVariable.CompareTo("Message") == 0)
            {
                this.m_strWelcomeMessage = strValue;
            }
            else if (strVariable.CompareTo("Yell welcome") == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
            {
                this.m_enYellResponses = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
            }
            else if (strVariable.CompareTo("Delay before sending welcome") == 0 && int.TryParse(strValue, out iTimeSeconds) == true)
            {
                this.m_iDelayBeforeSendingWelcome = iTimeSeconds;
            }
            else if (strVariable.CompareTo("Show welcome for how long") == 0 && int.TryParse(strValue, out iTimeSeconds) == true)
            {
                this.m_iWelcomeDisplayTime = iTimeSeconds * 1000;
            }

            // Rules
            else if (strVariable.CompareTo("Yell rules") == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
            {
                this.m_enYellResponsesRules = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
            }
            else if (strVariable.CompareTo("Delay before sending rules") == 0 && int.TryParse(strValue, out iTimeSeconds) == true)
            {
                this.m_iDelayBeforeSendingRules = iTimeSeconds;
            }
            else if (strVariable.CompareTo("Show rule for how long") == 0 && int.TryParse(strValue, out iTimeSeconds) == true)
            {
                this.m_iRuleDisplayTime = iTimeSeconds * 1000;
            }
            else if (strVariable.CompareTo("Delay between rules") == 0 && int.TryParse(strValue, out iTimeSeconds) == true)
            {
                this.m_iDelayBetweenRules = iTimeSeconds;
            }
            else if (strVariable.CompareTo("Chat Command") == 0)
            {
                this.m_strRulesCommandOld = this.m_strRulesCommand;
                this.m_strRulesCommand    = strValue;
            }
            else if (strVariable.CompareTo("Server Rules") == 0)
            {
                this.m_aServerRules = CPluginVariable.DecodeStringArray(strValue);
                int iloop = 0;
                foreach (string rule in this.m_aServerRules)
                {
                    if (rule.ToLower().IndexOf(this.m_strChatRulesRequest.ToLower()) >= 0)
                    {
                        this.m_aServerRules[iloop] = Regex.Replace(rule, this.m_strChatRulesRequest, "", RegexOptions.IgnoreCase);
                    }
                    iloop++;
                }
            }
            else if (strVariable.CompareTo("Ignore first line") == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
            {
                this.m_enIgnoreFirstLine = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
            }
            // Misc
            else if (strVariable.CompareTo("Default Sound") == 0)
            {
                this.m_audioFile = strValue;
            }
            else if (strVariable.CompareTo("Listen to Procon chat") == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
            {
                this.m_enListenToProconChat = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
            }
            else if (strVariable.CompareTo("GUI chat command") == 0)
            {
                this.m_strChatRulesRequest = strValue;
                int iloop = 0;
                foreach (string rule in this.m_aServerRules)
                {
                    if (rule.ToLower().IndexOf(this.m_strChatRulesRequest.ToLower()) >= 0)
                    {
                        this.m_aServerRules[iloop] = Regex.Replace(rule, this.m_strChatRulesRequest, "", RegexOptions.IgnoreCase);
                    }
                    iloop++;
                }
            }
            else if (strVariable.CompareTo("Privileges value") == 0 && int.TryParse(strValue, out iTmpValue) == true)
            {
                this.m_iMinPrivilegesValue = iTmpValue;
            }
            else if (strVariable.CompareTo("Take privileges of") == 0)
            {
                if (strValue.CompareTo("ExampleAccount") != 0)
                {
                    this.WritePluginConsole(String.Format("Checking privileges on {0}", strValue), 2);
                    CPrivileges cpAccount = this.GetAccountPrivileges(strValue);
                    if (cpAccount != null)
                    {
                        this.WritePluginConsole(String.Format("{0} has privilege value {1}", strValue, cpAccount.PrivilegesFlags.ToString()), 2);
                        this.m_iMinPrivilegesValue = (int)cpAccount.PrivilegesFlags;
                    }
                    else
                    {
                        this.WritePluginConsole(String.Format("There is no account {0}. Using default value.", strValue), 2);
                        this.m_iMinPrivilegesValue = this.m_iMinPrivilegesValueDefault;
                    }
                }
            }
            else if (strVariable.CompareTo("Debug output") == 0 && Enum.IsDefined(typeof(enumBoolYesNo), strValue) == true)
            {
                this.m_enDoDebugOutput = (enumBoolYesNo)Enum.Parse(typeof(enumBoolYesNo), strValue);
                if (this.m_enDoDebugOutput == enumBoolYesNo.No && this.m_enDoQuietMode == enumBoolYesNo.Yes)
                {
                    this.m_enDoConsoleOutput = enumBoolYesNo.Yes;
                }
            }

            this.UnregisterAllCommands();
            this.RegisterAllCommands();
        }
Exemplo n.º 12
0
        public void SetPluginVariable(string strVariable, string strValue)
        {
            if (Regex.Match(strVariable, @"Debug level").Success)
            {
                int tmp = 2;
                int.TryParse(strValue, out tmp);
                fDebugLevel = tmp;
            }

            if (Regex.Match(strVariable, @"Warmup Mode Boundary").Success)
            {
                int tmp = 32;
                int.TryParse(strValue, out tmp);
                warmupModeBoundarySetting = tmp;

                ConsoleWrite("(Settings) Warmup Mode Boundary = " + warmupModeBoundarySetting);
            }

            if (Regex.Match(strVariable, @"Full Mode Boundary").Success)
            {
                int tmp = 48;
                int.TryParse(strValue, out tmp);
                fullModeBoundarySetting = tmp;

                ConsoleWrite("(Settings) Full Mode Boundary = " + fullModeBoundarySetting);
            }

            if (Regex.Match(strVariable, @"Warmup Mode Ticket Percent").Success)
            {
                int tmp = 100;
                int.TryParse(strValue, out tmp);
                warmupModeTicketPercent = tmp;

                ConsoleWrite("(Settings) Warmup Mode Ticket Percent = " + warmupModeTicketPercent);
            }

            if (Regex.Match(strVariable, @"Full Mode Ticket Percent").Success)
            {
                int tmp = 100;
                int.TryParse(strValue, out tmp);
                fullModeTicketPercent = tmp;

                ConsoleWrite("(Settings) Full Mode Ticket Percent = " + fullModeTicketPercent);
            }

            if (Regex.Match(strVariable, @"IsChangeServerName").Success)
            {
                bool tmp = false;
                Boolean.TryParse(strValue, out tmp);
                isChangeServerNameSetting = tmp;

                ConsoleWrite("(Settings) IsChangeServerName = " + isChangeServerNameSetting);
            }

            if (Regex.Match(strVariable, @"Warmup Mode ServerName").Success)
            {
                warmupModeServerNameSetting = strValue;

                ConsoleWrite("(Settings) Warmup Mode ServerName = " + warmupModeServerNameSetting);
            }

            if (Regex.Match(strVariable, @"Full Mode ServerName").Success)
            {
                fullModeServerNameSetting = strValue;

                ConsoleWrite("(Settings) Full Mode ServerName = " + fullModeServerNameSetting);
            }


            if (Regex.Match(strVariable, @"Warmup Mode Maplist").Success)
            {
                this.warmupMaplistSetting = CPluginVariable.DecodeStringArray(strValue);
                this.LoadMapList();

                ConsoleWrite("(Settings) Warmup Mode Maplist Count = " + this.warmupMaplistSetting.Length);
            }

            if (Regex.Match(strVariable, @"Full Mode Maplist").Success)
            {
                this.fullMaplistSetting = CPluginVariable.DecodeStringArray(strValue);
                this.LoadMapList();

                ConsoleWrite("(Settings) Full Mode Maplist Count = " + this.fullMaplistSetting.Length);
            }
        }