SA-MP Forums Archive
[Include] random.inc - Random System - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] random.inc - Random System (/showthread.php?tid=536210)



random.inc - Random System - hesambia - 08.09.2014

Description
Now I Writed A Include That Just Do Two Very Important Work.This Include Simulate a C# Random Function.
(Note: This Include Based On 'native random(max);' And You Need a_samp.inc and float.inc)

Functions
Код:
native Random(min, max);
native RandomFloat(Float:min, Float:max, accuracy = 4);
The Important Benefits In This Include, Just The Min, Max Values And Random Float.
RandomFloat, Does Some Math Calculations To Return A Completly Random Float.

Return Values
Random:

A Random Value: Everything Is Right.
0: Something Is Wrong And A Error Occured.

Errors:
Max Value Is Equal Or Smaller From Min Value.
Min Or Max Values Are Negative.

RandomFloat:

A Random Float Value: Everything Is Right.
0.0: Something Is Wrong And A Error Occured.

Errors:
Accuracy Is Bigger From 6 Or Smaller From 1.
Max Value Is Equal Or Smaller From Min Value.
Min Or Max Values Are Negative.

Examples
Random(min, max):

Код:
printf("Random (10 - 65):%d",Random(10,65));
Output Can Be (65 - 10 =) 55 Items.Here Is Some Outputs:
Код:
Random 10 - 65:41
Random 10 - 65:17
Random 10 - 65:36
Random 10 - 65:57
Random 10 - 65:28
---------------------------
RandomFloat(Float:min, Float:max) :

Код:
printf("Random Float (5.1 - 44.7):%f",RandomFloat(5.1,44.7));
Output Can Be Too Many Items.Here Is Some Outputs(We Dont Put Accuracy; And its By Default 4):
Код:
Random Float (5.1 - 44.7):17.2981
Random Float (5.1 - 44.7):27.1247
Random Float (5.1 - 44.7):9.1954
Random Float (5.1 - 44.7):41.2458
Random Float (5.1 - 44.7):35.5884
Download
random.inc


Re: random.inc - Random System - iFarbod - 08.09.2014

Nice job. Take my rep+


Re: random.inc - Random System - KingServerIRAN - 08.09.2014

Good job bro REP+


Re: random.inc - Random System - Stinged - 08.09.2014

This shouldn't be an include as it's just 2 simple functions.


Re: random.inc - Random System - hesambia - 08.09.2014

What You Need?Its Just Declaring Two Function That Can Be Needed Sometimes.


Re: random.inc - Random System - amirab - 08.09.2014

not an include , useful but we can not use it as an include
because we can make it in 10seconds and use it as a stock in our gamemode
so why we should use another include for our gamemode?