SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 17/01/2014, 01:41 AM   #1
ZBits
Gangsta
 
Join Date: Dec 2011
Posts: 516
Reputation: 18
Default Random Numbers

Hello there, i've been tring to set a random number between 17 and 19 but its not working, it always comes out as 18.

Heres what i use for rand:

pawn Code:
//random(max- min) + min;
new rand = random(19 - 17) + 17;

Any help will be appriciated
ZBits is offline   Reply With Quote
Old 17/01/2014, 02:03 AM   #2
Ari
Banned
 
Join Date: Feb 2013
Location: /dev/retrd
Posts: 94
Reputation: 13
Default Re: Random Numbers

pawn Code:
stock minrand(min, max) //By Alex "******" Cole
{
    return random(max - min) + min;
}

pawn Code:
new rand = minrand(17, 19);
Ari is offline   Reply With Quote
Old 17/01/2014, 02:09 AM   #3
ZBits
Gangsta
 
Join Date: Dec 2011
Posts: 516
Reputation: 18
Default Re: Random Numbers

Thanks
ZBits is offline   Reply With Quote
Old 17/01/2014, 03:43 AM   #4
Snir_sofer
Little Clucker
 
Join Date: Jul 2010
Posts: 45
Reputation: 1
Default Re: Random Numbers

Very Faster:
PHP Code:
#define minrand(%0, %1) random(%1- %0) + %0 //By Alex "******" Cole 
Snir_sofer is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Random Numbers TuTh Scripting Help 1 04/11/2012 09:31 AM
Random numbers Jimbo01 Help Archive 2 01/02/2011 08:45 PM
[Help] Random numbers Rainbow_Six Help Archive 4 21/10/2010 07:08 PM
[HELP] Random numbers? SiJ Help Archive 6 09/08/2009 03:14 PM
Need help with random numbers... *BueNoOo* Help Archive 11 18/06/2009 05:13 PM


All times are GMT. The time now is 12:09 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.