Case sensitive user names.
#1

hello i want my login system to convert all nicks to lower case .. i mean if a player nick: TeST.. the file must be saved as test.ini..


P.S: edit my code..

here is code:

pawn Код:
stock Path(playerid) //Will create a new stock so we can easily use it later to load/save user's data in user's path
{
    new str[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(str,sizeof(str),UserPath, name);
    return str;
}
Reply
#2

they answered this for you already?

http://forum.sa-mp.com/showthread.ph...hlight=tolower

by using:

https://sampwiki.blast.hk/wiki/Tolower
Reply
#3

EDIT: Nevermind, too late.
Reply
#4

ok so like this?

pawn Код:
public NickToLower(const nick[])
{
    for(new i=0, j=strlen(nick); i<j; i++)
    {
        nick[i] = tolower(nick[i]);
    }
    return nick;
}
forward NickToLower(nick[]);
stock Path(playerid) //Will create a new stock so we can easily use it later to load/save user's data in user's path
{
    new str[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(str,sizeof(str),UserPath, NickToLower[name]);
    return str;
}

then i get these errors:
Код:
D:\1v1_Nouman_server\filterscripts\project.pwn(1675) : error 022: must be lvalue (non-constant)
D:\1v1_Nouman_server\filterscripts\project.pwn(1677) : error 090: public functions may not return arrays (symbol "NickToLower")
D:\1v1_Nouman_server\filterscripts\project.pwn(1679) : error 025: function heading differs from prototype
D:\1v1_Nouman_server\filterscripts\project.pwn(1684) : error 028: invalid subscript (not an array or too many subscripts): "NickToLower"
D:\1v1_Nouman_server\filterscripts\project.pwn(1684) : warning 215: expression has no effect
D:\1v1_Nouman_server\filterscripts\project.pwn(1684) : error 001: expected token: ";", but found "]"
D:\1v1_Nouman_server\filterscripts\project.pwn(1684) : error 029: invalid expression, assumed zero
D:\1v1_Nouman_server\filterscripts\project.pwn(1684) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


7 Errors.
Reply
#5

like this NickToLower(name)
Reply
#6

hello...

this code:

pawn Код:
public NickToLower(const nick[])
{
    for(new i=0, j=strlen(nick); i<j; i++)
    {
        nick[i] = tolower(nick[i]); // 1675
    }
    return nick;// 1677
}
forward NickToLower(nick[]); // 1679
stock Path(playerid) //Will create a new stock so we can easily use it later to load/save user's data in user's path
{
    new str[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(str,sizeof(str),UserPath, NickToLower(name));
    return str;
}

and now errors

Код:
D:\1v1_Nouman_server\filterscripts\project.pwn(1675) : error 022: must be lvalue (non-constant)
D:\1v1_Nouman_server\filterscripts\project.pwn(1677) : error 090: public functions may not return arrays (symbol "NickToLower")
D:\1v1_Nouman_server\filterscripts\project.pwn(1679) : error 025: function heading differs from prototype
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Reply
#7

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

stock Path(playerid) //Will create a new stock so we can easily use it later to load/save user's data in user's path
{
    new str[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(str,sizeof(str),UserPath, NickToLower(name));
    return str;
}
Don't use public to create functions.
Reply
#8

now i get this error:

Код:
D:\1v1_Nouman_server\filterscripts\project.pwn(1675) : error 022: must be lvalue (non-constant)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
on this line

pawn Код:
nick[i] = tolower(nick[i]);
Reply
#9

My bad i didn't notice const. This should look like this
pawn Код:
stock NickToLower(nick[]) //Just remove const
{
    for(new i=0, j=strlen(nick); i<j; i++)
    {
        nick[i] = tolower(nick[i]);
    }
    return nick;
}
Reply
#10

ok now .. if i use test name CRAZYBoB.. it should be converted to "crazybob.ini" (in script files) but i got
",€(јcrazybob.ini" (inside script files instead of "crazybob.ini")
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)