Solved C# Wait Until

Discussion in 'Rust Development' started by DylanSMR, Sep 15, 2016.

  1. So in SQF we have this:
    Code:
    waitUntil { not alive player }; //This is arma 3 code
    Is this possible in CSHarp? I know while() works but it seems to freeze the console for me. Any idea's?
     
  2. Can waitUntil contain arbitrary code or just specific keywords?

    EDIT: Nvm, I looked up the docs.
    OnTick with a condition is equivalent to waitUntil.
    Keep in mind that this may be very bad for performance and performs way worse than normal hooks.
     
  3. Yeah I knew it would be somewhat bad for server frames. In Arma they somewhat optimized it using a algorithm based on how the server is running. So either it checks every frame or every X(frames) dependent on the server stats at the time of check.
     
  4. Nondeterministic polling isn't useful for OnTick, though (and if you need it, you can implement it yourself rather easily too).
    I suggest staying away from OnTick until you really need it. There aren't many plugins that do.
     
  5. such Yield commands works only for nested classes:

    Code:
    using System.Collections;public class WaitUntilExample: MonoBehaviour {
        public int frame;    void Start() {
            StartCoroutine(Example());
        }
       
        IEnumerator Example() {
            Debug.Log("Waiting for princess to be resqued...");
            yield return new WaitUntil(() => frame >= 10);
            Debug.Log("Princess was resqued!");
        }    void Update() {
            if (frame <= 10)
            {
                Debug.Log("Frame: " + frame);
                frame++;
            }
        }
    }
     
  6. What exactly do you want to do if I may ask?
     
  7. Nothing as of now. Currently it was just a question honestly.