Mixed random numbers with letters [REPP ++]
#1

hey guys
i was searching for mixed letters and numbers but i couldnt find a tutorial or anything
if someone would show me would be very usefuly thanks in advanced
Reply
#2

pawn Код:
randomstr(string[], maxlength = sizeof (string))
{
    string[0] = EOS;
    for (new i; i < maxlength; i++)
            format(string, maxlength, "%s%c", string, (random(((126 - 33) + 1)) + 33));
    return 1;
}
Testing:
pawn Код:
main()
{
    new test[15];
    randomstr(test);
    print(test); // Result: "aO;@}_)02BDoGn"
}
Reply
#3

More details about what you want...
Reply
#4

Thanks that what i need

also how to get if player has writte the random numbers

for example
ShowPlayerDialog(playerid, 300,DIALOG_STYLE_INPUT,"Testing","Write [Random nr]" etc etc

then at response how to know if the player has used those numbers ?
Reply
#5

Use strcmp.

pawn Код:
if (!strcmp(inputtext, "the random string"))
{
    // match
}
Reply
#6

Thank you.
Repped +
Reply
#7

Humm how can i remove the !Ј} etc ??
Reply
#8

Quote:
Originally Posted by Gammix
Посмотреть сообщение
format(string, maxlength, "%s%c", string, (random(((126 - 33) + 1)) + 33));
That's considerably slow, format + strcat is a better option.
Reply
#9

can you gimme something else @SickAttack
just simple numbers and letters
example A2T31SA
not needed for Ј!Ј%
Reply
#10

Create an array with the characters you want to appear in the string and do the same thing Gammix did (using random values from the array), but using strcat instead of format.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)