I am trying to trigger a function on 00:00.
Obviously that does not work so I did this: "(TOD_Sky.Instance.Cycle.Hour >= 23.99)".Code:void OnTick() { if (TOD_Sky.Instance.Cycle.Hour == 0) // 00:00 { //do something } }
Is there a better way to do this?
Triggering function based on time
Discussion in 'Rust Development' started by Reynostrum, Jul 10, 2016.
-
If I'm not mistaken, then you can add callbacks to TOD_Time.OnDay. Haven't tried it, though.
-
Sorry sqroot, I am a little confused. Can you explain it a little more?
Thank you. -
TOD_Time has a member OnDay:
TOD_Time can be accessed like: TOD_Sky.Instance.Components.TimeCode:public event Action OnDay { [MethodImpl(MethodImplOptions.Synchronized)] add { this.OnDay = (Action)Delegate.Combine(this.OnDay, value); } [MethodImpl(MethodImplOptions.Synchronized)] remove { this.OnDay = (Action)Delegate.Remove(this.OnDay, value); } }
The rest is C# specific
-
Something simple I use to reference Time of day and do something
Used similar coding for my fishing plugin to give bonus to fishing in morning and evening.
Just a idea
Code:float currenttime = TOD_Sky.Instance.Cycle.Hour; if (currenttime < 8 && currenttime > 6) { MakeMyCoffee(player, strong); }Last edited by a moderator: Jul 11, 2016
