How to make it random -
JaKe Elite - 27.10.2012
Hey i'm creating a agent card.
I want to make it random numbers, how to make it in random numbers?
like
Код:
AgentCard = 00912842315
Agent Card is a integer not a string.
Re: How to make it random -
park4bmx - 27.10.2012
pawn Код:
new AgentCard = random(800000);//the highest random number
Re: How to make it random -
JaKe Elite - 27.10.2012
Is there limit number in random?
Cause i wanna make it random up to 11 length numbers so it will be really look like a cellphone number (look a like but it works different)
Re: How to make it random -
park4bmx - 27.10.2012
don't think so as i use it to randomize X,Y,Z positions which are pretty long.
But if you want to keep it short you can
random two numbers and add them together
Re: How to make it random - Emmet_ - 27.10.2012
There is, it's
2,147,483,647 which is the maximum 32-bit integer in PAWN (signed).
If you want an 11 length number:
pawn Код:
new rand1 = random(500000 - 100000) + 100000;
new rand2 = random(50000 - 10000) + 10000;
new string[64];
format(string, sizeof(string), "%d%d", rand1, rand2);
Re: How to make it random -
JaKe Elite - 27.10.2012
thanks both of you..
Re: How to make it random -
iPLEOMAX - 27.10.2012
You can set random numbers to a string (because a 32-bit cell has limitations in it's capacity to hold a very large number)
pawn Код:
stock SetRandomNumber(string[], size = sizeof string)
{
for(new i; i < size; i++) string[i] = 48 + random(10);
return string;
}
//Usage:
public OnFilterScriptInit()
{
new MyString[16]; //<-- array size is the number of digits
SetRandomNumber(MyString);
printf("%s", MyString);
return 1;
}
Re: How to make it random -
_Khaled_ - 27.10.2012
PHP код:
new filestring[128];
format(filestring, sizeof(filestring), "scriptfiles/Administration/Users/%s.ini", pname);
new arand =random(2,147,483,647);
new INI:File = INI_Open(filestring);
INI_SetTag(File,"Player's Data");
INI_WriteInt(File, "Agent Numer",arand);
INI_Close(File);
For Y_INI
Re: How to make it random -
iPLEOMAX - 27.10.2012
Why don't you change it to string?
INI_WriteString(...);
Re: How to make it random -
JaKe Elite - 28.10.2012
^^
I already did it change to string, i use Emmet_'s code.