Converting Nicks to lower case upon register/login
#1

Hello.. i have a register system in which system cant detect that nick: Anak, anak, or ANAK is same and Anak, anak, or ANAK will be different accounts.. i want to convert all nicks to lower case upon register / login.

i have this stock path:

pawn Код:
stock Path(playerid)
{
    new str[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(str,sizeof(str),UserPath, name);
    return str;
}
i have this on login / register

pawn Код:
new INI:file = INI_Open(Path(playerid));
thanks...
Reply
#2

tolower()
Reply
#3

Quote:
Originally Posted by MP2
Посмотреть сообщение
tolower()
where i use this?
Reply
#4

pawn Код:
stock Path(playerid)
{
    new str[128],name[MAX_PLAYER_NAME] = tolower(name[128]);
    GetPlayerName(playerid,name,sizeof(name));
    format(str,sizeof(str),UserPath, name);
    return str;
}
As an example, not 100% sure if it will work as i cant test atm.
Reply
#5

nope didn't worked..
Reply
#6

pawn Код:
public NickToLower(nick[])
{
    for(new i = 0; i <strlen(nick);i++)
    {
        nick[i] = tolower(nick[i]);
    }
    return nick;
}
I didnt test.
Reply
#7

tolower takes a character as a parameter, not a string. You need to loop through the string and use tolower() on every individual character.

EDIT: StreetGT beat me. I'd suggest some minor changes though:

pawn Код:
public NickToLower(const nick[])
{
    for(new i=0, j=strlen(nick); i<j; i++)
    {
        nick[i] = tolower(nick[i]);
    }
    return nick;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)