Solved Using timers?

Discussion in 'Rust Development' started by Bananas_In_Pajamas, Nov 15, 2017.

  1. I can't seem to create an instance of the Timer class but can use one of its functions as if it were static ( timer.Repeat() ). But when I look inside the Timer class definition it doesn't appear to be static. Also the Timer class starts with an uppercase T but the timer.Repeat function is called with a lowercase t? The Timer class I am looking at is inside the Oxide.Core Assembly. Could someone please explain the Timer class to me and why this is happening?


    This works:
    Code:
    void OnPluginLoaded(Plugin name)
    {
                timer.Repeat(60f, 100, spawnCar);
    }

    This does not work:
    Code:
    void OnPluginLoaded(Plugin name)
    {
                Timer t = new Timer();
                t.Repeat(60f, 100, spawnCar);
    }
    Error from code example #2
    Code:
    Error while compiling: CarSpawn.cs(33,15): error CS1061: Type `Oxide.Plugins.Timer' does not contain a definition for `Repeat' and no extension method `Repeat' of type `Oxide.Plugins.Timer' could be found. Are you missing an assembly reference?
     
  2. I didn't know there was a reference on how to use timers on the API page. Would have saved me all that time looking for the Timer class and searching through other people's plugins looking for their implementation of timers.

    Thanks.
     
  3. It’s a lower case T because “timer” is an instance of the “Timer” class.

    Having the timer instance upper case would cause conflicts.