PDA

View Full Version : Case sensitive user names.


Anak
27/07/2013, 12:47 PM
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:


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

Donvalley
27/07/2013, 12:48 PM
they answered this for you already?

http://forum.sa-mp.com/showthread.php?t=453246&highlight=tolower

by using:

http://wiki.sa-mp.com/wiki/Tolower

JimmyCh
27/07/2013, 12:51 PM
EDIT: Nevermind, too late.

Anak
27/07/2013, 01:02 PM
ok so like this?


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(167 5) : error 022: must be lvalue (non-constant)
D:\1v1_Nouman_server\filterscripts\project.pwn(167 7) : error 090: public functions may not return arrays (symbol "NickToLower")
D:\1v1_Nouman_server\filterscripts\project.pwn(167 9) : error 025: function heading differs from prototype
D:\1v1_Nouman_server\filterscripts\project.pwn(168 4) : error 028: invalid subscript (not an array or too many subscripts): "NickToLower"
D:\1v1_Nouman_server\filterscripts\project.pwn(168 4) : warning 215: expression has no effect
D:\1v1_Nouman_server\filterscripts\project.pwn(168 4) : error 001: expected token: ";", but found "]"
D:\1v1_Nouman_server\filterscripts\project.pwn(168 4) : error 029: invalid expression, assumed zero
D:\1v1_Nouman_server\filterscripts\project.pwn(168 4) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


7 Errors.

Nero_3D
27/07/2013, 01:13 PM
like this NickToLower(name)

Anak
27/07/2013, 02:49 PM
hello...

this code:


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(167 5) : error 022: must be lvalue (non-constant)
D:\1v1_Nouman_server\filterscripts\project.pwn(167 7) : error 090: public functions may not return arrays (symbol "NickToLower")
D:\1v1_Nouman_server\filterscripts\project.pwn(167 9) : error 025: function heading differs from prototype
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.

QuaTTrO
27/07/2013, 02:56 PM
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.

Anak
27/07/2013, 03:04 PM
now i get this error:


D:\1v1_Nouman_server\filterscripts\project.pwn(167 5) : error 022: must be lvalue (non-constant)
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Error.



on this line


nick[i] = tolower(nick[i]);

QuaTTrO
27/07/2013, 03:19 PM
My bad i didn't notice const. This should look like this

stock NickToLower(nick[]) //Just remove const
{
for(new i=0, j=strlen(nick); i<j; i++)
{
nick[i] = tolower(nick[i]);
}
return nick;
}

Anak
27/07/2013, 03:26 PM
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")

Jefff
27/07/2013, 04:12 PM
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));

for(new d,len = strlen(name); d != len; d++)
name[d] = tolower(name[d]);

format(str,sizeof(str),UserPath,name);
return str;
}

Anak
27/07/2013, 06:25 PM
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));

for(new d,len = strlen(name); d != len; d++)
name[d] = tolower(name[d]);

format(str,sizeof(str),UserPath,name);
return str;
}


ok now with this i'm having successful register and login.. (file is saving in small case.. ) :)

but the problem is.. now OnPlayerDisconnect stats are not saving here is code:
(It is also not printed in server console)


if(fexist(Path(playerid)))
{// then
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Players_Data");
INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]);
INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]);
INI_WriteInt(file,"Money",GetPlayerMoney(playerid));
INI_WriteInt(file,"Scores",GetPlayerScore(playerid));
INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);
INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);
INI_WriteInt(file,"Adisable",pInfo[playerid][Adisable]);
INI_WriteInt(file,"Banned",pInfo[playerid][Banned]);
INI_WriteInt(file,"Pills",pInfo[playerid][Pills]);
INI_WriteInt(file,"Savedskin",pInfo[playerid][Savedskin]);
INI_WriteInt(file,"Last",pInfo[playerid][Last]);
INI_WriteInt(file,"NoPM",pInfo[playerid][NoPM]);
INI_WriteInt(file,"Drugs",pInfo[playerid][Drugs]);
INI_Close(file);//Now after we've done saving their data, we now need to close the file
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,24);
new str[120];
format(str,sizeof(str),"<SAVED> Stats for account: %s(%d) has been saved successfully.", playername, playerid);
print(str);
}

Anak
28/07/2013, 05:29 AM
pls any one?

SwisherSweet
28/07/2013, 05:39 AM
Are you calling it on onplayerdisconnect like a stock or something

Anak
28/07/2013, 07:15 AM
read previous posts clears .. any one can help me... with this http://forum.sa-mp.com/showpost.php?p=2633451&postcount=12