GetRandomNumber

Discussion in 'Rust Development' started by FireBurst, Sep 8, 2015.

  1. Hi where can I find examples of GetRandomNumber? plugins or web scripts.

    I try to get a list of locs on the map and randomly spawn players on them when dead
    (no dont refer me to spawns plugin or events/jail I know they use it but I couldnt make it done well. so im doing it on my own.

    I just dont want a min max locs.

    1: x=111 y=222 z=333
    2: x=444 y=555 z=666
    3: x=777 y=888 z=999
    etc

    random between 1 to 3 and get that loc to use.
    Any help to get reference examples?

    EDIT: nevermind got it to work
     
    Last edited by a moderator: Sep 8, 2015
  2. Random.Range(1,3);
    ? I saw that somewhere in Unity forums ;x
     
  3. You could do like I do with Cornucopia and reuse collectible spawns.
     
  4. Calytic

    Calytic Community Admin Community Mod

    That shouldn't be difficult. You have an array or List of Vectors..
    Code:
    List<Vector3> positions = new List<Vector3>();
    To retrieve a random element from the List using System.Random
    Code:
    System.Random rnd = new System.Random();int r = rnd.Next(positions.Count);Vector3 randomPosition = positions[r];
    Alternatively using Oxide.Core.Random
    Code:
    int r = Oxide.Core.Random.Range(0, positions.Count-1);Vector3 randomPosition = positions[r];