Detecting a character in a players name
#1

Hey guys, I have a /changename cmd but I only jsut realized that people can put spaces and shit in there name and it fucks up the MySQL database. So whats the best way I could check if theres any spaces or unwanted characters in the players name?
Reply
#2

mysql_real_escape_string.
Reply
#3

Quote:
Originally Posted by T0pAz
Посмотреть сообщение
Yes but... I mean.. if a player uses a space in his name, SetPlayerName will not work. So how can I return a message to say that they are not allowed to use a space in there name? I know about the mysql_real_escape_string.
Reply
#4

pawn Код:
stock IsValidName(name[])
{
    if(strlen(name) < 3) return 0;
    new i, ch;
    while ((ch = name[i++]) && ((ch == '(') || (ch == ')') || (ch == '$') || (ch == '.') || (ch == '=') || (ch == '@') || (ch == ']') || (ch == '[') || (ch == '_') || ('0' <= ch <= '9') || ((ch |= 0x20) && ('a' <= ch <= 'z')))) {}
    return !ch;
}
Reply
#5

Thanks man, that really helped. Sorry for such a late reply too!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)