RandInt: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Visual improvement)
 
(7 intermediate revisions by 6 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
==Description==
{{Server function}}
{{Deprecated|math.random}}
 
This function returns a random integer value between a specified minimum and maximum value.
This function returns a random integer value between a specified minimum and maximum value.


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">randInt ( lowerbound, upperbound )</syntaxhighlight>
<syntaxhighlight lang="lua">int randInt ( int lowerbound, int upperbound )</syntaxhighlight>


===Required Arguments===
===Required Arguments===
* '''lowerbound''': This is the lowest random value this function can return.
* '''lowerbound:''' This is the lowest random value this function can return.
* '''upperbound''': This is the highest random value this function can return.
* '''upperbound:''' This is the highest random value this function can return.
 
===Returns===
Returns an [[int]] containing a random number between and potentially including ''lowerbound'' and ''upperbound''.


==Example==
==Example==
<syntaxhighlight lang="lua">outputChatBox ( "A random value between 5 and 10 is ", randInt ( 5, 10 ) )</syntaxhighlight>
This example outputs a random number between 5 and 10 inclusive.
<syntaxhighlight lang="lua">
outputChatBox ( "A random value between 5 and 10 is " .. randInt ( 5, 10 ) )
</syntaxhighlight>
 
==See Also==
{{Utility functions}}

Latest revision as of 12:16, 26 June 2014

Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions.

Please use math.random instead.


This function returns a random integer value between a specified minimum and maximum value.

Syntax

int randInt ( int lowerbound, int upperbound )

Required Arguments

  • lowerbound: This is the lowest random value this function can return.
  • upperbound: This is the highest random value this function can return.

Returns

Returns an int containing a random number between and potentially including lowerbound and upperbound.

Example

This example outputs a random number between 5 and 10 inclusive.

outputChatBox ( "A random value between 5 and 10 is " .. randInt ( 5, 10 ) )

See Also