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
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
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]
LIES Random(5) is 0,1,2,3 or 4 and not 5!!
Infractions, reputation, reflection, the dark side of scripting, they are.
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]
i know why, sorry, my fault
[IMG]http://farm3.static.flickr.com/2120/2052732965_348f3629d0_o.jpg[/IMG]
Thanks Guys I will try and put this into action in my script. Major thanks to Lordgreggreg
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]
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.
There are currently 1 users browsing this thread. (0 members and 1 guests)