1. Hi im looking to make a timer repeat itself every 5 minutes, the plugin currently has

    "AutoTimers.Add(timer.Once(TimeBuild, () => StartFightPhase()));"

    I took a look at the timer basics in the docs but that doesnt seem to help me i need it to say how long is currently left (Still new to working with plugins)
     
  2. Wulf

    Wulf Community Admin

    Code:
    timer.Every(300f, () => StartFightPhase();
     
  3. Seemed to do the trick but its switching game phase every 5 minutes instead of displaying how long is left, "Build Phase" is set to last for 30 minutes then its meant to switch to "Fight Phase".
     
  4. Why not do something like:
    Code:
    const double totalDuration = 1800.0;
    const double notificationInterval = 300.0;
    var leftoverTime = totalDuration;
    timer.Once(totalDuration, StartFightPhase);
    timer.Repeat(notificationInterval, (int) (totalDuration / notificationInterval), () =>
    {
        leftoverTime -= notificationInterval;
        // broadcast leftoverTime
    });
    EDIT: Replaced 300 with notificationInterval
     
    Last edited by a moderator: Sep 12, 2016
  5. Im new to this plugin side of things so i may sound a little stupid but how would i change it to that? lol xD
    Code:
    private void StartBuildPhase()
            {
                DestroyTimers();
                BuildPhase = false;            BroadcastToChat(lang.GetMessage("Title", this) +
                            lang.GetMessage("BuildPhase", this));
              
                BroadcastToChat(string.Format(lang.GetMessage("Title", this) +
                    lang.GetMessage("BuildPhaseTime", this),
                    (TimeBuild / 60).ToString()));            //Build Rate
                CraftingRate = CraftBuild;            //Gather Rate
                GatherRate = BuildGatherMulti;
              
                //Update
                UpdateGatherRate();
                UpdateCraftingRate();            //Timers
                PhaseStart = DateTime.Now.AddMinutes(TimeBuild / 60);
                AutoTimers.Add(timer.Every(300f, () => StartFightPhase()));        }