RandomUtils
FivePD.API.Utils
#
Namespace: Source/Utils/RandomUtils.cs
#
File: HB-2012
#
Made by: A collection of utilities that make it easier to select or generate random values.
#
Fields#
RandomThis is reasonably slower than using new Random(), but since all callouts get loaded at the same time, we shouldn't use the same seed (by default the system time is used, leading to very bad randomization). Unfortunately, this isn't thread-safe, but that shouldn't be a problem with FivePD.
Random instance that you can use to get random values in your callouts. This random should generate better
random numbers than when you create your own randoms in code. Also have a look at the GetRandomNumber
method.
#
Properties#
PedHasesA list of all entries in the PedHash
enum, minus the ones that break FivePD.
#
WeaponHashesA list of all entries in the WeaponHash
enum.
#
VehicleHasesA list of all entries in the VehicleHash
enum.
#
Methods#
GetRandomNumberSelects a random number in the specified range. start
is inclusive, end
exclusive (so the number that is passed for start
can also be returned, but end
cannot).
Returns a number between start
and end
(could be equal to start
).
Returns: int
Params:
- start
- Type: int
- The inclusive minimum value
- end
- Type: int
- The exclusive maximum value
#
ExampleTo generate an inclusive number between 1 and 100, you would use the following code:
var myRandomNumber = GetRandomNumber(1, 101);
#
GetRandomPedReturns a random PedHash
.
By default, this method will already exclude all skins that are incompatible with FivePD.
Returns: PedHash
Params: -
#
GetRandomWeaponReturns a random WeaponHash
.
Entries in the exclusion list will be ignored.
Returns: WeaponHash
Params:
- exclusions
- Type: IEnumerable<WeaponHash>
- A list of
WeaponHash
to ignore
#
GetRandomVehicleReturns a random VehicleHash
.
Returns: Vehicle
Params: -
#
GetRandomVehicleReturns a random VehicleHash
.
Entries in the exclusion list will be ignored.
Returns: VehicleHash
Params:
- exclusions
- Type: IEnumerable<VehicleHash>
- A list of
VehicleHash
to ignore
#
GetRandomVehicleReturns a random VehicleHash
from the given vehicle class.
Returns: VehicleHash
Params:
- vehicleClass
- Type: VehicleClass
- The class of vehicles you wish to select a random hash from
#
GetRandomVehicleReturns a random VehicleHash
from the given vehicle classes.
Returns: VehicleHash
Params:
- vehicleClass
- Type: params VehicleClass[]
- The classes of vehicles you wish to select a random hash from
#
GetRandomVehicleReturns a random VehicleHash
from the given vehicle classes.
Returns: VehicleHash
Params:
- vehicleClass
- Type: IEnumerable<VehicleClass>
- The classes of vehicles you wish to select a random hash from
#
GetVehicleHashesForClassRetrieves all of the VehicleHash
es from a given VehicleClass
.
Returns: IEnumerable<VehicleHash>
Params:
- vehicleClass
- Type: VehicleClass
- The classes of vehicles