Running function on a timer every second?Solved

Since I can't use the System Timer, how can I achieve this with Oxide?

using System;

namespace Oxide.Plugins
{
    [Info("Restarter", "Lazeer", "0.01")]
    public class Restarter : RustPlugin
    {
        void Init()
        {
            Puts("Waiting for restart command");
        }
        [ConsoleCommand("timedrestart")]
        private void TestCommand()
        {
            Puts("Server Restart in 5 minutes.");
            //Server.Broadcast("Server Restart in 5 minutes.");
            timer.Repeat(3f, 0, () =>
            {
                Puts("I will run once every second");
            });
        }
    }
}

Currently it's not running every one second but rather every 3 frames. How can I make it execute every 1 second?

(19:22:05) | [Restarter] 1 second
(19:22:08) | [Restarter] 1 second
(19:22:11) | [Restarter] 1 second
(19:22:14) | [Restarter] 1 second

 

I hope I posted this in the right place. It's a Rust specific plugin.

Tried setting second value to 3?
5b6ed4c9ac8e4.jpg misticos
Tried setting second value to 3?

Thank you for the quick reply!

The second value, isn't that for repeats only?

I think its for repeats tho and it should not behave like shown so thats weird
5b6ed4c9ac8e4.jpg misticos
I think its for repeats tho and it should not behave like shown so thats weird

Yeah, it is kinda weird. 3 frames should occur way more often then that.

Since you've been developing plugins for uMod for a long while, do you have any strategy on how to overcome this?

All I want is a Timer that runs every 1 second basically, but I can't use the System Timer in the Oxide.Plugins namespace.

 

Use timer.Every(1f, () => {});
5b6ed4c9ac8e4.jpg misticos
Use timer.Every(1f, () => {});

That seems to work, but why on earth is it working?

(20:04:08) | [Restarter] 1 second
(20:04:09) | [Restarter] 1 second
(20:04:10) | [Restarter] 1 second
(20:04:11) | [Restarter] 1 second

 

I thought 1f equals to 1 frame, not 1 second?

It accepts seconds not frames
Locked automatically