26.06.2017, 21:11
Hey all.
I use random(max) to get a random number
is there any way to get a random string ?
I use random(max) to get a random number
is there any way to get a random string ?
stock minrandom(min, max)
return min + random(max - min);
new randomString[10];
for(new i; i < sizeof randomString; i++)
{
randomString[i] = minrandom('A', 'Z');
}
GenString( string[ ] , size = sizeof string )
{
static const Data[ ] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";//add more characters if they want to include in string
new i;
for(i = 0 ; i < size; ++i)
string[ i ] = Data[ random( sizeof Data ) ];
}
new string[10];
GenString(string);
printf("random string : %s ",string);
pawn Код:
pawn Код:
|
CMD:provahash(playerid, params[])
{
new str[256];
new strfull[10], strnf[10];
format(str, sizeof(str), "{FFFFFF}Full: {FFFF00}%s", RandomStringFull(strfull));
SendClientMessage(playerid, -1, str);
format(str, sizeof(str), "{FFFFFF}no full: {FFFF00}%s", RandomString(strnf));
SendClientMessage(playerid, -1, str);
format(str, sizeof(str), "{FFFFFF}numbers: {FFFF00}%d", random(999999999));
SendClientMessage(playerid, -1, str);
return 1;
}
RandomString( string[ ] , size = sizeof string )
{
static const Data[ ] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";//add more characters if they want to include in string
new i;
for(i = 0 ; i < size; ++i)
string[ i ] = Data[ random( sizeof Data ) ];
}
RandomStringFull( string[ ] , size = sizeof string )
{
static const Data[ ] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!Ј$%&/()=?'^мий+*тза°щ§,;.:-_<>";//add more characters if they want to include in string
new i;
for(i = 0 ; i < size; ++i)
string[ i ] = Data[ random( sizeof Data ) ];
}
I tryied this code like this...but pawno give me 2 warning, who told me about the functions that should have a return value, how I fix that?
pawn Код:
|
new string[50]; RandomString(string); // string will now contain the random string