Random number
#1

Hello,

Can anyone help me with pointing out how can i add a code that gets random 10 digit number but with same 3 digits first...like:

1625060504
1621306123
1626023010

Thanks!
Reply
#2

pawn Код:
format(string, sizeof (string), "162%i%i%i%i%i%i%i", random(10), random(10), random(10), random(10), random(10), random(10), random(10));
Reply
#3

Function
PHP код:
stock randomEx(minmax)
{    
    
//Credits to ******    
    
new rand random(max-min)+min;    
    return 
rand;

Usage
PHP код:
RandomEx(16200000001630000000); 
My method seems to be better but correct me if I'm wrong.
Reply
#4

Thank you both!

Would this work?

Код:
new phonenumber = RandomEx(1620000000, 1630000000);		
PlayerInfo[playerid][pnumber] = phonenumber;
Код:
stock randomEx(min, max)
{
    //Credits to ******
    new rand = random(max-min)+min;
    return rand;
}
Reply
#5

Quote:
Originally Posted by Mrki_Drakula
Посмотреть сообщение
Thank you both!

Would this work?

Код:
new phonenumber = RandomEx(1620000000, 1630000000);		
PlayerInfo[playerid][pnumber] = phonenumber;
Код:
stock randomEx(min, max)
{
    //Credits to ******
    new rand = random(max-min)+min;
    return rand;
}
That should work, unless your [pnumber] is a float.
Reply
#6

Its says undefined randomEx even when i put the stock...
Reply
#7

follow Konstantinos method it's more easy
Reply
#8

Quote:
Originally Posted by Azula
Посмотреть сообщение
follow Konstantinos method it's more easy
It's a hard way of doing it while it could be done easier.

Quote:
Originally Posted by Mrki_Drakula
Посмотреть сообщение
Its says undefined randomEx even when i put the stock...

also it says undefined phonenumber
Are you sure you used it correctly?

Here's an example:
PHP код:
stock randomEx(minmax)
{    
    
//Credits to ******    
    
new rand random(max-min)+min;    
    return 
rand;
}
CMD:randomnumber(playeridparams[])
{
    new 
value RandomEx(16200000001630000000);
    
printf("the value is %d"value);
    return 
1;

Reply
#9

C:\Users\Crysis\Desktop\MusaBM.pwn(49709) : error 017: undefined symbol "RandomEx"

PHP код:
new brojtelefona RandomEx(16200000001630000000);
PlayerInfo[playerid][pnumber] = brojtelefona
and somewhere at the start

PHP код:
stock randomEx(minmax)
{
    
//Credits to ******
    
new rand random(max-min)+min;
    return 
rand;

EDIT: Wow wait i copied your code and havent seen the mistype
Reply
#10

Quote:
Originally Posted by Mrki_Drakula
Посмотреть сообщение
C:\Users\Crysis\Desktop\MusaBM.pwn(49709) : error 017: undefined symbol "RandomEx"

PHP код:
new brojtelefona RandomEx(16200000001630000000);
PlayerInfo[playerid][pnumber] = brojtelefona
and somewhere at the start

PHP код:
stock randomEx(minmax)
{
    
//Credits to ******
    
new rand random(max-min)+min;
    return 
rand;

It's randomEx, not RandomEx.
It might be useful to read the function name first.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)