1. Sharpstar

    Sharpstar Scavenger

    Greetings,

    I am working on a plugin at the moment and it is giving me the following error:

    The type or namespace name `Tasks' does not exist in the namespace `System.Threading'. Are you missing an assembly reference?

    From what I can see, it is because System.Treading.Tasks was introduced for .NET 4.0. So is Oxide compiling for .NET 3.5 or something?

    The library seems to be there, but it is not finding this.

    Thoughts?
     
  2. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Oxide uses .NET 3.5 as shown in the project files on GitHub, and can't use anything higher as Unity3D (the engine Rust uses) requires 3.5 due to the old Mono version it uses.
     
  3. Sharpstar

    Sharpstar Scavenger

    Interesting. I will have to find another way then.
    --- Double Post Merged, Jul 27, 2015 ---
    Actually, Reactive Extensions has a dll for this specific .NET 4.0+ feature, but I am not sure how I would go about that. Apparently I need to add a reference to the back ported standalone DLL named System.Threading.dll that will allow me to use this.
     
  4. hulu123

    hulu123 Naked Wanderer Plugin Developer

    I am interested in this feature as well.
    Is it possible to compile oxide for rok to use the 4.0 framework?
    I have written a plugin that do many calculations and if i called it in oncubeplacement than often the server crashs when the execution time is to long. So I wanted to do calculations in a different thread but that is not possible.
    Do anyone know a solution?
     
  5. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    No, the version of Mono that Unity uses is not compatible with 4.0. .NET 3.5 is the highest we can use that I am aware of. I believe there are ways to do threading, but I believe it's risky, and could lead to other issues.
     
  6. Sharpstar

    Sharpstar Scavenger

    Well, then my primary question would be how to put a delay between two commands if I cannot use the System.Treading.Tasks?

    What I really want is for the plugin to run a command and then repeat that command again without any further prompting. In .NET 4.0+ I could use a timed task, but I am not sure how to do it with 3.5.
     
  7. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    You could use Oxide's timer system.
     
  8. Sharpstar

    Sharpstar Scavenger

    So how would that look for something simple like just allowing the plugin to run a command and then repeat it? Such as this?

    Code (Text):
    timer.Once(3, () => Whatever.Command
    timer.In(3, () => Whatever.Command
    If not, what might be an easy way to do this? I read the API documentation, but I did not understand this particular section. Sorry for being lost xD
     
  9. Mughisi

    Mughisi Grenade Master Community Mod Oxide Developer

    Repeating timers would do the trick, http://docs.oxidemod.org/rok/#repeating-timer
     
  10. Sharpstar

    Sharpstar Scavenger

    How does that work? What does the 10,0, define?

    timer.Repeat(10, 0, () => PrintToChat("Hello world!"));
     
  11. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Delay and repetitions, 0 is infinite.
     
  12. Sharpstar

    Sharpstar Scavenger

    So 5,1 will run the command, delay 5 seconds, run it again, and then stop?
     
  13. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Yup! And if you want to do two repeats, 5, 2.
     
  14. Sharpstar

    Sharpstar Scavenger

    Excellent. Seems like it is resolving the issue we were having.
     
  15. deusprox

    deusprox Wood Hoarder

    Did they update to Net 4.0?
     
  16. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Unity (the game engine RoK uses) still uses .NET 3.5.
     
    deusprox likes this.