Home   Help Search Login Register  

Author Topic: Random Numbers  (Read 764 times)

0 Members and 1 Guest are viewing this topic.

StonedSoldier

  • Guest
Random Numbers
« on: 22 Jan 2004, 20:50:48 »
when using;

Code: [Select]
_rand = random 50
_num = _rand - (_rand2 mod 1)

the random number that is generated is between 0 - 60. is there a way to generate a random number between -10 and + 10.

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:Random Numbers
« Reply #1 on: 22 Jan 2004, 21:04:58 »
OK, before i solve it for you, i'll give you the chance to solve
it yourself (*think simple math way*)

What would you need to to to change:

0 - 20

to:

-10 - 10

Now define your random result at a range: 0 - 20
and alter the result as you need to do in my math-riddle
above.  ;)

:edit - ah yeah, btw - random 50 creates a number from
0 to 50, and not from 0 to 60

~S~ CD
« Last Edit: 22 Jan 2004, 21:06:47 by Chris Death »
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

StonedSoldier

  • Guest
Re:Random Numbers
« Reply #2 on: 22 Jan 2004, 21:37:48 »
errrrmmmm......still lost the plot,

could you give more detail please

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:Random Numbers
« Reply #3 on: 22 Jan 2004, 21:42:20 »
OK then here we go:

if you want to alter a range from: 0 - 20
to: -10 - 10

all you need to do is: remove 10

create a random value between 0 and 20, and remove the
value of 10 from the result. Now you have a value from -10
to 10

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Random Numbers
« Reply #4 on: 22 Jan 2004, 21:42:36 »
Try this:

_rand = (random 20) - 10

:beat: *Gets Shot* :beat:

EDIT: Crap, Chirs was faster... :P
« Last Edit: 22 Jan 2004, 21:43:07 by The real Armstrong »