Hi, how can i create a random number in MMF2. Im trying to create a random gape of 0-3 seconds before a race starts but cant find anything in the search =(
Hi, how can i create a random number in MMF2. Im trying to create a random gape of 0-3 seconds before a race starts but cant find anything in the search =(


The function is Random(Maximum value)- for a random number (0, 1, 2, 3) use Random(4).
Like Jam(ie) said, use the "random( [color:#CC0000]<insert highest number here>[/color] )"
So if you put random([color:#CC0000]5[/color]) it would pick any random number between 0 and 5.
But if you want a number from 10 to 20, not 0 to 20 you need to do
[color:#CC0000]10[/color] + random([color:#CC0000]20[/color])
![]()
shouldn't it beOriginally Posted by Dynamite
[color:#CC0000]10[/color] + random([color:#CC0000]10[/color])
cheers. I am trying to get it to start between 0-3 seconds to hundreds of a seconds. so say liek 1.34 or 2.43s but im now having trouble with getting MMF to recognise when this happens. I have set two counters. One to Random(4) and one to random(100) and then comparing two global values checking seconds and hundreds values. I then tried creating another two counters to always keep value of timer seconds and timer hundreds (displays fine on screen) but sometimes MMF will start race ok and other times it will 'miss' and not start at all =( Thanks for the help!
For 10 to 20, it would actually be 10 + Random(11).Originally Posted by KetchupMaster
Well I am still having trouble finding out what you want but Im guessing you want to choose a random number between 0 and 3 and the number represents seconds.
What you do is change [color:#993399]Global Value A[/color], re-name it "[color:#993399]time[/color]".
Also, change [color:#009900]Global Value B[/color], re-name it "[color:#009900]random_time[/color]"
Do:
[color:#3333FF]Every 1 mili second[/color] -- [color:#CC0000]Add 1 to [color:#993399]Global Value "time"[/color][/color].
Now since you want it to start from the nearest mili second, instead of randomizing the numbers 0 to 3, you need to randomize them from 0 to 300.
[color:#3333FF]Start of frame[/color] -- [color:#CC0000]Set [color:#009900]Global Value "random_time"[/color] to "Random(300)"
[/color]
Now you do:
[color:#3333FF]Compare 2 general values, [color:#993399]Global value "time"[/color] is equal to [color:#009900]Global value "random_time"[/color][/color]
-- Perform action
Hope it helped! (:
Don't compare if the time is equal to the number. Check if it is equal or GREATER than.
minutes >= random_minutes
seconds >= random_seconds
> do something great
Thanks very much!! =) Using greater than solved the problem of not always picking up the values. Genius =)