So .. again some small issues.
Issue nr1.
In my function with a line of the timer look like:
I want to destroy it in "void Unload" so i dont know how to do it in C#..Code:var timerrepeat = timer.Repeat(1, 0, () => test);
Solved Destroying timers? (C#)
Discussion in 'Rust Development' started by PaiN, Jul 3, 2015.
-
store timer variable in the field of the script.
Code:using Oxide.Plugins;namespace MyPlugin { [Info("MyPlugin", "ZakBelg", 0.1, ResourceId = 714)] [Description("Awesome timer workout")] public class TestPlugin : RustPlugin { private Timer _timer; void Init() { var timerInstance = new Oxide.Core.Libraries.Timer.TimerInstance(1000, 1000, null, this); _timer = new Timer(timerInstance); } void Unload() { if (!_timer.Destroyed) _timer.Destroy(); } } }
-
Done it worked.. now One last question..
So for example lets say that i want activate a timer to display them a message to TWO targets.
Then i want to stop it from the one of them and the other's one timer will keep going.
Is it possible to "assign" the timer to a player? for ex /repeathim "Hello" -
Either you need two timers or filter unwanted player in a callback of single timer by checking some expression.
-
If it's the same message you send to everyone, simply have a of targets (List<BasePlayer>()) (global) that you add/remove players to/from. In the timer function loop through them and send the msg.
-
is there any difference using this type of timer (other than i think u can pass parameters through oxides one) or using c#'s one ?
void Unload()
{
timer.Stop();
}
void Loaded()
{
timer = new System.Timers.Timer(600000);
timer.Interval = 600000;
timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
timer.Start();
} -
Wulf Community Admin