random: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (How to get whole number)
m (moved command to template, MP behavior needs updating.)
Line 4: Line 4:
[[Category:Scripting Commands ArmA|RANDOM]]
[[Category:Scripting Commands ArmA|RANDOM]]


{{Command|= Comments
____________________________________________________________________________________________


<h2 style="color:#000066">'''random ''x'''''</h2>
| ofp |= Game name


|1.00|= Game version
____________________________________________________________________________________________


'''Operand types:'''
| Random real value from 0 to x. |= Description
____________________________________________________________________________________________


'''x:''' [[Number]]
| '''random''' x |= Syntax


'''Type of returned value:'''
|p1= x: [[Number]] |= Parameter 1


[[Number]]
| [[Number]] |= Return value
____________________________________________________________________________________________
 
|x1= <pre>_rNumber = random 1
|= Example 1
____________________________________________________________________________________________


'''Description:'''
|  |= See also


Random real value from 0 to '''x'''.
}}


<h3 style="display:none">Notes</h3>
<dl class="command_description">
<!-- Note Section BEGIN -->


'''Example:'''
Be careful using random numbers in multiplayer, each client will come up with a different result. See multiplayer tutorials for more general information about locality.
The number returned is unlikely to be a whole number (e.g. 1, 4, 76, etc.). To return a whole number combine '''random''' and [[mod]]:</pre>


_rNumber = '''random''' 1
<!-- Note Section END -->
</dl>


 
<h3 style="display:none">Bottom Section</h3>
'''Comments'''
 
Be careful using random numbers in multiplayer, each client will come up with a different result.
 
See multiplayer tutorials for more general information about locality.
 
 
The number returned is unlikely to be a whole number (e.g. 1,  4, 76, etc.).
 
To return a whole number combine [[random]] and [[mod]]:
<pre>_ran = random 10
_ran = _ran - (_ran % 1)
</pre>

Revision as of 02:53, 3 August 2006


{{Command|= Comments ____________________________________________________________________________________________

| ofp |= Game name

|1.00|= Game version ____________________________________________________________________________________________

| Random real value from 0 to x. |= Description ____________________________________________________________________________________________

| random x |= Syntax

|p1= x: Number |= Parameter 1

| Number |= Return value ____________________________________________________________________________________________

|x1=

_rNumber = random 1 
|= Example 1
____________________________________________________________________________________________

|  |= See also

}}

<h3 style="display:none">Notes</h3>
<dl class="command_description">
<!-- Note Section BEGIN -->

Be careful using random numbers in multiplayer, each client will come up with a different result. See multiplayer tutorials for more general information about locality. 
The number returned is unlikely to be a whole number (e.g. 1, 4, 76, etc.). To return a whole number combine '''random''' and [[mod]]:

Bottom Section