Results 1 to 8 of 8

Thread: Randomising script

  1. #1
    Join Date
    Dec 2006
    Posts
    56
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Randomising script

    Hey, I have been working on my really nooby wcer script for a while now and I was wondering if there was anything about getting SCAR to choose something itself randomly based on nothing but flipping a coin. Any help much appreciated
    Norrisemoe

  2. #2
    Join Date
    Apr 2007
    Location
    Texas
    Posts
    1,668
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    yep

    random(x) generates a random number from 0 to x

    so random(5) can make either a 0,1,2,3,4,5

    coin fliping would be like random(1)

    or mabey something like if(random(1)=1) then writeln('random time');

    wait(1000+random(3000)); will wait between 1 and 4 seconds.
    [IMG]http://farm3.static.flickr.com/2120/2052732965_348f3629d0_o.jpg[/IMG]

  3. #3
    Join Date
    Nov 2006
    Posts
    1,103
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    LIES Random(5) is 0,1,2,3 or 4 and not 5!!
    Infractions, reputation, reflection, the dark side of scripting, they are.

  4. #4
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    You forgot to explain why

    Arrays always start from 0 I believe...
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

  5. #5
    Join Date
    Apr 2007
    Location
    Texas
    Posts
    1,668
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i know why, sorry, my fault
    [IMG]http://farm3.static.flickr.com/2120/2052732965_348f3629d0_o.jpg[/IMG]

  6. #6
    Join Date
    Dec 2006
    Posts
    56
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks Guys I will try and put this into action in my script. Major thanks to Lordgreggreg

  7. #7
    Join Date
    Apr 2007
    Location
    Texas
    Posts
    1,668
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    you very welcome.

    i belive either the wiki, the srl manual, or the scar manual covers that for you...

    they are very good resources.

    if not, tutorials got them covered. but i dont mind giving further explaniation on anything.

    keep up the good work learning.
    [IMG]http://farm3.static.flickr.com/2120/2052732965_348f3629d0_o.jpg[/IMG]

  8. #8
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You might also want to look at these

    Random functions

    function Random(Range: Integer): Integer;
    Returns random 0 <= number < Range. Random(5) will return any of values 0, 1, 2, 3, 4. Random(5) + 1 will return values 1..5.

    function RandomRange(From, To: Integer): Integer;
    Returns a random value between From and To.

    function RBool: Boolean;
    Returns a random boolean.

    function Rand: Extended;
    Returns a random extended value between 0 and 1.

    function RBoolEx(Chance: Integer): Boolean;
    Returns a True with a chance of 1/Chance.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •