Ejemplo n.º 1
0
        void EventCheck()
        {
            if (!days.Contains(DateTime.Now.ToUniversalTime().ToString("ddd")))
            {
                return;
            }
            else
            {
                foreach (var storedEvent in storedData.Events)
                {
                    if (storedEvent.EventDate.Date <= DateTime.UtcNow && !storedEvent.broadcast)
                    {
                        Puts(storedEvent.EventDate.Date.ToString() + " <= " + DateTime.UtcNow.ToString());
                        if (storedEvent.CommandLine == "")
                        {
                            SendNotification(storedEvent.EventInfo, Convert.ToInt16(Config["Plugin", "PopUpTime"]));
                        }
                        else
                        {
                            var rust = new Oxide.Game.Rust.Libraries.Rust();

                            string args = storedEvent.CommandLine.Remove(0, storedEvent.CommandLine.IndexOf(" ") + 1);

                            string command = storedEvent.CommandLine.Substring(0, storedEvent.CommandLine.IndexOf(" "));
                            rust.RunServerCommand(command, args);
                        }
                        switch (storedEvent.Schedule.ToLower())
                        {
                        case "hourly":
                            while (storedEvent.EventDate.Date <= DateTime.UtcNow)
                            {
                                storedEvent.EventDate = storedEvent.EventDate.AddHours(1);
                            }
                            break;

                        case "daily":
                            while (storedEvent.EventDate.Date <= DateTime.UtcNow)
                            {
                                storedEvent.EventDate = storedEvent.EventDate.AddDays(1);
                            }
                            break;

                        case "weekly":
                            while (storedEvent.EventDate.Date <= DateTime.UtcNow)
                            {
                                storedEvent.EventDate = storedEvent.EventDate.AddDays(7);
                            }
                            break;

                        case "monthly":
                            while (storedEvent.EventDate.Date <= DateTime.UtcNow)
                            {
                                storedEvent.EventDate = storedEvent.EventDate.AddMonths(1);
                            }
                            break;

                        case "yearly":
                            while (storedEvent.EventDate.Date <= DateTime.UtcNow)
                            {
                                storedEvent.EventDate = storedEvent.EventDate.AddYears(1);
                            }
                            break;

                        default:
                            storedEvent.broadcast = true;
                            break;
                        }
                        Interface.GetMod().DataFileSystem.WriteObject("MyEvents", storedData);
                    }
                }
                // Check for Events on that day
                Interface.GetMod().DataFileSystem.WriteObject("MyEvents", storedData);
            }
        }
Ejemplo n.º 2
0
        void EventCheck()
        {
            if (!days.Contains(DateTime.Now.ToUniversalTime().ToString("ddd")))
            {
                return;
            } else {
                foreach(var storedEvent in storedData.Events)
                {
                    if(storedEvent.EventDate.Date.ToUniversalTime() <= DateTime.Now.ToUniversalTime() && !storedEvent.broadcast)
                    {
                        Puts(storedEvent.EventDate.Date.ToUniversalTime() + " <= " + DateTime.Now.ToUniversalTime());
                        if (storedEvent.CommandLine == "")
                        {
                            SendNotification(storedEvent.EventInfo, Convert.ToInt16(Config["Plugin", "PopUpTime"]));
                        } else
                        {
                            var rust = new Oxide.Game.Rust.Libraries.Rust();
                            string args = "";
                            string command = "";
                            try
                            {
                                args = storedEvent.CommandLine.Remove(0, storedEvent.CommandLine.IndexOf(" ") + 1);

                                command = storedEvent.CommandLine.Substring(0, storedEvent.CommandLine.IndexOf(" "));
                            } catch
                            {
                                command = storedEvent.CommandLine;
                            }
                            rust.RunServerCommand(command, args);
                        }
                        switch (storedEvent.Schedule.ToLower())
                        {
                            case "hourly":
                                while (storedEvent.EventDate.Date.ToUniversalTime() <= DateTime.Now.ToUniversalTime())
                                {
                                    storedEvent.EventDate = storedEvent.EventDate.AddHours(1);
                                    Puts("NotifyFired");
                                }
                                break;
                            case "daily":
                                while (storedEvent.EventDate.Date.ToUniversalTime() <= DateTime.Now.ToUniversalTime())
                                {
                                    storedEvent.EventDate = storedEvent.EventDate.AddDays(1);
                                }
                                break;
                            case "weekly":
                                while (storedEvent.EventDate.Date.ToUniversalTime() <= DateTime.Now.ToUniversalTime())
                                {
                                    storedEvent.EventDate = storedEvent.EventDate.AddDays(7);
                                }
                                break;
                            case "monthly":
                                while (storedEvent.EventDate.Date.ToUniversalTime() <= DateTime.Now.ToUniversalTime())
                                {
                                    storedEvent.EventDate = storedEvent.EventDate.AddMonths(1);
                                }
                                break;
                            case "yearly":
                                while (storedEvent.EventDate.Date.ToUniversalTime() <= DateTime.Now.ToUniversalTime())
                                {
                                    storedEvent.EventDate = storedEvent.EventDate.AddYears(1);
                                }
                                break;
                            default:
                                storedEvent.broadcast = true;
                                break;
                        }
                        Interface.GetMod().DataFileSystem.WriteObject("MyEvents", storedData);
                    }
                }
                // Check for Events on that day
                Interface.GetMod().DataFileSystem.WriteObject("MyEvents", storedData);

            }
        }