SA-MP Forums Archive
Random Number and Text - 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: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Random Number and Text (/showthread.php?tid=399074)



Random Number and Text - CrazyChoco - 12.12.2012

Hello folks!
I want to do it like when he example do:
pawn Код:
CMD:random(playerid, params[])
{

return 1;
}
Then a random generated number and text within 16 chars(8 numbers & 8 textchars if possbile) will be shown up in a ClientMessage for player only.

I mean like it will maybe show a code like this: 12E1011Q1P9WSURM

or something similar to that.

Thanks


Re: Random Number and Text - Mike_Peterson - 12.12.2012

https://sampforum.blast.hk/showthread.php?tid=276913

Look at Ryder's post


Re: Random Number and Text - CrazyChoco - 12.12.2012

You mean this:
Quote:
Originally Posted by RyDeR`
Посмотреть сообщение
pawn Код:
stock randomString(strDest[], strLen = 10)
{
    while(strLen--)
        strDest[strLen] = random(2) ? (random(26) + (random(2) ? 'a' : 'A')) : (random(10) + '0');
}
Example:
pawn Код:
new
    string[10]
;
randomString(string, 10);
I tried to read the code, but clearly don't understand it. If anyone is willing to just explain what it does ill be very happy to listen!


Re: Random Number and Text - Mike_Peterson - 12.12.2012

Well, I'm not such a maths fanatic either but, I suppose the parameters aren't so hard, randomString(string,length);
string is the variable in which u want to store the characters in, new string[17];
then length is the amount of characters u want, so 16.

Код:
new string[17];
randomString(string,16);
I suppose this should work.