Gameplay::getRandomIntInRange: Difference between revisions
(yay) |
(yay) |
||
| Line 1: | Line 1: | ||
Another extremely useful native.<br><br>You can use it simply like:<br>if (GAMEPLAY::GET_RANDOM_INT_IN_RANGE(0, 2))<br><br>and the if-statement will count it as false only if the random int is 0. That means there is a one in three chance of it being false. Put a '!' in front and it means there is a one in three chance of it being true. | Another extremely useful native.<br><br>You can use it simply like:<br>if (GAMEPLAY::GET_RANDOM_INT_IN_RANGE(0, 2))<br><br>and the if-statement will count it as false only if the random int is 0. That means there is a one in three chance of it being false. Put a '!' in front and it means there is a one in three chance of it being true. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="javascript">gameplay.getRandomIntInRange(startRange, endRange);</syntaxhighlight> | <syntaxhighlight lang="javascript">mp.game.gameplay.getRandomIntInRange(startRange, endRange);</syntaxhighlight> | ||
=== Required Arguments === | === Required Arguments === | ||
*'''startRange:''' int | *'''startRange:''' int | ||
| Line 9: | Line 9: | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
todo | // todo | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See also== | ==See also== | ||
{{ | {{Gameplay_s_function_c}} | ||
[[Category:Clientside API]] | [[Category:Clientside API]] | ||
[[Category:TODO: Example]] | [[Category:TODO: Example]] | ||
Revision as of 21:12, 6 May 2017
Another extremely useful native.
You can use it simply like:
if (GAMEPLAY::GET_RANDOM_INT_IN_RANGE(0, 2))
and the if-statement will count it as false only if the random int is 0. That means there is a one in three chance of it being false. Put a '!' in front and it means there is a one in three chance of it being true.
Syntax
mp.game.gameplay.getRandomIntInRange(startRange, endRange);
Required Arguments
- startRange: int
- endRange: int
Return value
- int
Example
// todo