SA-MP Forums Archive
Converting Nicks to lower case upon register/login - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Converting Nicks to lower case upon register/login (/showthread.php?tid=453246)



Converting Nicks to lower case upon register/login - Anak - 24.07.2013

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...


Re: Converting Nicks to lower case upon register/login - MP2 - 24.07.2013

tolower()


Re: Converting Nicks to lower case upon register/login - Anak - 24.07.2013

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


Re: Converting Nicks to lower case upon register/login - Donvalley - 24.07.2013

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.


Re: Converting Nicks to lower case upon register/login - Anak - 24.07.2013

nope didn't worked..


Re: Converting Nicks to lower case upon register/login - StreetGT - 24.07.2013

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


Re: Converting Nicks to lower case upon register/login - MP2 - 24.07.2013

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;
}