Beispiel #1
0
        //----------------------------------Starter-----------------------------//

        //Load
        protected override void Load()
        {
            Instance = this;
            if (Configuration.Instance.MathQuestionsEnabled)
            {
                Rocket.Core.Logging.Logger.LogWarning("MathQuestions - Enabled");
            }
            else
            {
                Rocket.Core.Logging.Logger.LogError("MathQuestions - Disabled");
            }
        }
Beispiel #2
0
        private void AutoQuestion()
        {
            Automation = this;
            if (Configuration.Instance.MathQuestionsEnabled)
            {
                try
                {
                    if (State == PluginState.Loaded && Configuration.Instance.Interval != 0 && (timer == null || ((DateTime.Now - timer.Value).TotalMinutes > Configuration.Instance.Interval)))
                    {
                        number1 = autonumber.Next(8, 85);
                        number2 = autonumber.Next(10, 97);

                        if (Configuration.Instance.Addition && !Configuration.Instance.Subtraction)
                        {
                            operation = "+"; result = number1 + number2;
                        }
                        if (!Configuration.Instance.Addition && Configuration.Instance.Subtraction)
                        {
                            operation = "-"; result = number1 - number2;
                        }

                        if (Configuration.Instance.Addition == Configuration.Instance.Subtraction)
                        {
                            autoperation = autonumber.Next(1, 3);
                            switch (autoperation)
                            {
                            case 1: operation = "+"; result = number1 + number2; break;

                            case 2: operation = "-"; result = number1 - number2; break;
                            }
                        }

                        MathQuestions.ExecuteDependencyCode("Uconomy", (IRocketPlugin plugin) =>
                        {
                            Uconomy Uconomy  = (Uconomy)plugin;
                            string broadcast = Translate("mathquestions_broadcast_question", number1.ToString(), number2.ToString(), operation, Configuration.Instance.Reward.ToString(), Uconomy.Configuration.Instance.MoneyName);
                            UnturnedChat.Say(broadcast, UnturnedChat.GetColorFromName(Configuration.Instance.MessageColor, UnityEngine.Color.yellow));
                        });
                        timer      = DateTime.Now;
                        NoQuestion = false;
                    }
                }
                catch (Exception old)
                {
                    Rocket.Core.Logging.Logger.LogException(old);
                }
            }
            else
            {
                Automation = null;
            }
        }
        //----------------------------------Starter-----------------------------//

        //Load
        protected override void Load()
        {
            Instance = this;
            if (Configuration.Instance.MathQuestionsEnabled)
            {
                Rocket.Core.Logging.Logger.LogWarning("             +------------------Math-Questions-----------------+");
                Rocket.Core.Logging.Logger.LogWarning("             |                  Coder: CapScroLL               |");
                Rocket.Core.Logging.Logger.LogWarning("             |-------------------------------------------------|");
                Rocket.Core.Logging.Logger.LogWarning("             |              youtube.com/CapScroLL              |");
                Rocket.Core.Logging.Logger.LogWarning("             |         steamcommunity.com/id/CapScroLL         |");
                Rocket.Core.Logging.Logger.LogWarning("             +------------------Math-Questions-----------------+");
            }
            else
            {
                Rocket.Core.Logging.Logger.LogError("             +------------------Math-Questions-----------------+");
                Rocket.Core.Logging.Logger.LogError("             |                     DISABLED                    |");
                Rocket.Core.Logging.Logger.LogError("             +------------------Math-Questions-----------------+");
            }
        }
Beispiel #4
0
        public void ExecuteCommandCevap(IRocketPlayer caller, string[] answer)
        {
            try {
                UnturnedPlayer player = (UnturnedPlayer)caller;
                if (NoQuestion)
                {
                    string noquestion = Translate("mathquestions_no_question");
                    UnturnedChat.Say(caller, noquestion, UnturnedChat.GetColorFromName(Configuration.Instance.UnfavorableMessageColor, UnityEngine.Color.red));
                }
                else
                {
                    if (answer.Length >= 1)
                    {
                        if (answer[0] == result.ToString() && !NoQuestion)
                        {
                            NoQuestion = true;
                            MathQuestions.ExecuteDependencyCode("Uconomy", (IRocketPlugin plugin) =>
                            {
                                Uconomy Uconomy = (Uconomy)plugin;
                                Uconomy.Database.IncreaseBalance(player.CSteamID.ToString(), Configuration.Instance.Reward);
                                {
                                    string rightanswer = Translate("mathquestions_true_answer", Configuration.Instance.Reward.ToString(), Uconomy.Configuration.Instance.MoneyName, Uconomy.Database.GetBalance(player.CSteamID.ToString()));
                                    UnturnedChat.Say(player, rightanswer, UnturnedChat.GetColorFromName(Configuration.Instance.MessageColor, UnityEngine.Color.yellow));

                                    string winner = Translate("mathquestions_broadcast_winner", caller.DisplayName, result.ToString(), Configuration.Instance.Reward.ToString(), Uconomy.Configuration.Instance.MoneyName);
                                    UnturnedChat.Say(winner, UnturnedChat.GetColorFromName(Configuration.Instance.MessageColor, UnityEngine.Color.yellow));
                                }
                            });
                        }
                        if (answer[0] != result.ToString() && !NoQuestion)
                        {
                            UnturnedChat.Say(caller, Translate("mathquestions_wrong_answer"), UnturnedChat.GetColorFromName(Configuration.Instance.UnfavorableMessageColor, UnityEngine.Color.red));
                        }
                    }
                    else
                    {
                        UnturnedChat.Say(caller, Translate("mathquestions_invalid_parameter"), UnturnedChat.GetColorFromName(Configuration.Instance.MessageColor, UnityEngine.Color.yellow));
                    }
                }
            }
        }
Beispiel #5
0
 //Unload
 protected override void Unload()
 {
     Instance   = null;
     Automation = null;
     Rocket.Core.Logging.Logger.LogError("[Math Questions] Unloaded!");
 }