[HELP] Invalid username
#1

Hy, when a player connects to my server, i run a query to see if his name is in the database, but for some time, a player keeps coming with invalid characters in his name and crashes the server.
Can anyone please provide a piece of code that will check if player has only [a-z][A-Z][0-9] characters in his name?
Reply
#2

Might work, did not test:

pawn Код:
stock IsValidUsername(const string[])
{
    for (new i, s = strlen(string); i < s; ++i)
    {
        if ((string[i] < 48) || (string[i] > 57 && string[i] < 65) || (string[i] > 90 && string[i] < 97 && string[i] != 95) || (string[i] > 122)) return 0;
    }
    return 1;
}
Reply
#3

Works like a charm, thx.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)