RoomService v2.3.1
Loading...
Searching...
No Matches
RoomService.GenerateRandomNumber Class Reference

Lua function to generate a random number.

Member Function Documentation

◆ Implementation()

int RoomService.GenerateRandomNumber.Implementation ( int min,
int max )
inlineprivate

Usage:

Lua function to generate a random number.
Definition RoomServiceLuaFunctions.cs:1027
Definition MyPluginInfo.cs:2
Parameters
minThe minimum value (inclusive).
maxThe maximum value (inclusive).
Returns
A random integer between min and max.
Return values
int

Source Code

1046 {
1047 // Ensure min is less than or equal to max to prevent errors.
1048 if (min > max)
1049 {
1050 return min;
1051 }
1052
1053 Random random = new Random();
1054 return random.Next(min, max + 1); // max is inclusive.
1055 }