Incorrect permission info and performance

1. your commad intro is incorrect
you state:

disease.info
disease.admin
it is not, it is:
diseases.admin
diseases.info

you define :
private const string PermissionInfo = "diseases.info";​

but never reference them.

also maybe.. you never actually  wege the commands.....
so you cannot actually grant them.....

also on performance, your "ontick()" its a fair amount of work......
Certainly during a major outbreak...

Thank you for point this out, I have updated the documentation to correcly reflect the permission names. I will also look into what I can do about the performance.

Hi,
It looks like a fun plugin.

since it's not absolutly time critical, maybe  have a counter , mod  n in your ontick.
Set a boolean flag, fireup a secondary process., and check in your Mod n routine for the flag being set before starting a new process.

move all your ontick code to that process, then in your exit routine clear the boolean flag.
you could use a timer, but  Recenlty ive seen a lot of timer failures.

also .... don't forget the lowly  admin...
pls add the commands to the  "console" so you dont have to be in game to get info.......


Hi,
Just saw this before the update.
just incase your two fixes did nto take care of it.

Failed to call hook 'OnTick' on plugin 'Diseases v1.0.1' (NullReferenceException: )
  at (wrapper managed-to-native) UnityEngine.Component.get_transform(UnityEngine.Component)
  at BaseCombatEntity.Hurt (System.Single amount, Rust.DamageType type, BaseEntity attacker, System.Boolean useProtection) [0x0000c] in <a34e7683b69f4178abf09c977fe4da3e>:0 
  at Oxide.Plugins.Diseases.AttemptSpread (Oxide.Plugins.Diseases+Disease disease, Oxide.Plugins.Diseases+InfectedEntity spreader) [0x000d8] in <f8ee7cb93d1c49f58cc993da8c8b76d8>:0 
  at Oxide.Plugins.Diseases.OnTick () [0x000c9] in <f8ee7cb93d1c49f58cc993da8c8b76d8>:0 
  at Oxide.Plugins.Diseases.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00527] in <f8ee7cb93d1c49f58cc993da8c8b76d8>:0 
  at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00079] in <80b90e8213db44b29ec2d4111764172c>:0 
  at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x000d8] in <ec05e0208c9149bba43236ca58fea105>:0 
  at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00060] in <ec05e0208c9149bba43236ca58fea105>:0 
Unloaded plugin Diseases v1.0.1 by mr01sam​
FQ8U9mFWrPZLGdj.jpg razorfishsl

Hi,
It looks like a fun plugin.

since it's not absolutly time critical, maybe  have a counter , mod  n in your ontick.
Set a boolean flag, fireup a secondary process., and check in your Mod n routine for the flag being set before starting a new process.

move all your ontick code to that process, then in your exit routine clear the boolean flag.
you could use a timer, but  Recenlty ive seen a lot of timer failures.

That sounds like a great method to look into. Do you happen to know of any existing plugins that are creating additional processes that I can use as reference? I wasn't aware that was an option (I'm very new to rust plugins), but it sounds like the correct way of doing it.

I'm new to rust plugis as well, only a year or so..
Theres a lot of smarter more experienced guys who should be able to give you a hand.....

Just keep in mind that say for example if  ontick code take 1ms to  execute with 1 player..
what's gong to happen when the server has 150 players..  it's going to maybe hit reentrancy issues that are real hard to track down.
I've seen that with a number of plugins, and its usually rust that throws internal errors related to "comparators" or lists. "not being the same"

Oxide doesn't allow multi threading due to sandboxing. Even if it did, it probably wouldn't be appropriate for most use cases. Usually what people should be using are coroutines/timers.

In the case of this plugin, the solution is going to depend on exactly what you want to do. Assuming the tick delays are static (e.g., always N seconds), I would recommend simply a repeating timer like timer.Every(1, () => {...}) in OnServerInitialized(). If you want to do different types of things on different intervals, then you could use multiple timers, even multiple per disease. Timers are managed by Oxide and will be automatically destroyed on plugin unload. I wouldn't worry about "timer failures". That's usually just a mistake in coding, where the developer failed to check the state in the timer callback, such as whether particular entities are still around.

If you need something more advanced, such as a dynamic delay between timer intervals, you could use coroutines. Simply search the plugin listing for "StartCoroutine" to find some examples. A coroutine will also need to be explicitly stopped in the plugin Unload method.