[18:46:12] Incoming connection: 127.0.0.1:65185
[18:46:12] [join] [A]Gangs has joined the server (1:127.0.0.1)
[18:46:16] [REGISTERED] [A]Gangs registered with pass testing [Hashed - 203293439]
[18:51:17] [part] [A]Gangs has left the server (1:1)
[18:51:26] --- Server Shutting Down.
[18:51:47] [join] [A]Gangs has joined the server (1:127.0.0.1)
[18:51:48] [LOGIN] Fail login of [A]Gangs with password testing [Hashed - 203293439]
[19:14:12] [LOGIN] Fail login of [A]Gangs with password testing [Hashed - 203293439]
[19:14:13] [LOGIN] Fail login of [A]Gangs with password testing [Hashed - 203293439]
[19:14:14] [LOGIN] Fail login of [A]Gangs with password testing [Hashed - 203293439]
[19:14:15] [LOGIN] Fail login of [A]Gangs with password testing [Hashed - 203293439]
[19:14:16] [LOGIN] Fail login of [A]Gangs with password testing [Hashed - 203293439]
case DIALOG_LOGIN:
{
if (!response) return Kick (playerid);
if(response)
{
if(udb_hash(inputtext) == pInfo[playerid][Password])
{
INI_ParseFile(getini(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, pInfo[playerid][Money]);
printf("[LOGIN] Success login of %s with password %s [Hashed - %d] ", pname(playerid), inputtext, udb_hash(inputtext) );
ShowPlayerDialog(playerid, DIALOG_LOGIN_SUCCESS, DIALOG_STYLE_MSGBOX,"Success!","You have successfully logged in!","Ok","");
}
else
{
printf("[LOGIN] Fail login of %s with password %s [Hashed - %d] ", pname(playerid), inputtext, udb_hash(inputtext) );
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit");
}
return 1;
}
if(fexist(getbanini(playerid)))
{
SendClientMessage(playerid, RED, "[ERROR] You're banned! Stop ban evading! ");
KickEx(playerid);
}
else
{
if(fexist(getini(playerid)))
{
INI_ParseFile(getini(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","Type your password below to login.","Login","Quit");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Registering...","Type your password below to register a new account.","Register","Quit");
SendClientMessage(playerid, CYAN, "[SeRbErSShSHhs] W3lcUm t0 d4 sErVer");
}
stock LoadUser_data(pid,name[],value[])
{
INI_Int("Password",pInfo[pid][Password]);
INI_Int("Money",pInfo[pid][Money]);
INI_Int("AdminLevel",pInfo[pid][ALevel]);
INI_Int("VIPLevel", pInfo[pid][VIPLevel]);
INI_Int("Kills",pInfo[pid][Kills]);
INI_Int("Deaths",pInfo[pid][Deaths]);
INI_Int("Helper", pInfo[pid][Helper]);
INI_Int("Password", pInfo[pid][Helper]);
INI_Int("Experience", pInfo[pid][Experience]);
INI_Int("Banned", pInfo[pid][Banned]);
return 1;
}
I'm trying to read only ONE variable from the player's file, And INI_ParseFile loads all data, which I don't want to. |
Originally Posted by ******
I intend to add the option to load individual values later, but there's rarely any need if you do things properly
|
I /q and I come back, password works fine |
1. And this is what sets apart a good file system from a dini one (whoops mean't bad).
Reading and writing information are all here, https://sampforum.blast.hk/showthread.php?tid=175565. If you truly want help, let us see what you've attempted first (concept is OK). 2. debug info doesn't show this step assuming you followed this tutorial, show your data for registration. |
stock RegisterUser(pid, pass)
{
if(fexist(getini(pid))) return 0;
if(!IsPlayerConnected(pid)) return 0;
else
{
new INI:uh = INI_Open(getini(pid));
INI_SetTag(uh, "data");
INI_WriteString(uh, "Name", pname(pid) );
INI_WriteString(uh, "IP", pip(pid) );
INI_WriteInt(uh, "Password", pass);
pInfo[pid][Password] = pass;
INI_WriteInt(uh, "Kills", pInfo[pid][Kills]);
INI_WriteInt(uh, "Deaths", pInfo[pid][Deaths]);
INI_WriteInt(uh, "Experience", pInfo[pid][Experience]);
INI_WriteInt(uh, "Helper", pInfo[pid][Helper]);
INI_WriteInt(uh, "AdminLevel", pInfo[pid][ALevel]);
INI_WriteInt(uh, "VIPLevel", pInfo[pid][VIPLevel]);
INI_WriteInt(uh, "Banned", 0);
INI_Close(uh);
}
return 1;
}
stock SaveUser(pid)
{
if(!fexist(getini(pid))) return 0;
if(!IsPlayerConnected(pid)) return 0;
else
{
new INI:uh = INI_Open(getini(pid));
INI_SetTag(uh, "data");
INI_WriteString(uh, "Name", pname(pid) );
INI_WriteString(uh, "IP", pInfo[pid][IP] );
INI_WriteInt(uh, "Password", pInfo[pid][Password]);
INI_WriteInt(uh, "Kills", pInfo[pid][Kills]);
INI_WriteInt(uh, "Deaths", pInfo[pid][Deaths]);
INI_WriteInt(uh, "Experience", pInfo[pid][Experience]);
INI_WriteInt(uh, "Money", pInfo[pid][Money]);
INI_WriteInt(uh, "Helper", pInfo[pid][Helper]);
INI_WriteInt(uh, "AdminLevel", pInfo[pid][ALevel]);
INI_WriteInt(uh, "VIPLevel", pInfo[pid][VIPLevel]);
INI_WriteInt(uh, "Banned", pInfo[pid][Banned]);
INI_Close(uh);
}
return 1;
}
1. Create a seperate data tag for achievements
2. Create a function to load the var tags from that INI tag WITHOUT reading the [data], only reading [achievements]? |
if you plan on having multiple achievments creating a separate tag would work (as intended?) (y_ini's beauty i say). If you list everything under one tag, just read the data and store it for further use.
quick tip -> it'd be best to ONLY save frequently changing data (health, positions etc.) when disconnecting and the rest when modified (then and there). This way, you know certain data will ALWAYS save (the semi-important ones) and as for ones that may change constantly are not likely as important. |
INI_ParseFile(getini(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
stock LoadUser_data(pid,name[],value[])
{
INI_Int("Password",pInfo[pid][Password]);
INI_Int("Money",pInfo[pid][Money]);
INI_Int("AdminLevel",pInfo[pid][ALevel]);
INI_Int("VIPLevel", pInfo[pid][VIPLevel]);
INI_Int("Kills",pInfo[pid][Kills]);
INI_Int("Deaths",pInfo[pid][Deaths]);
INI_Int("Helper", pInfo[pid][Helper]);
INI_Int("Password", pInfo[pid][Helper]);
INI_Int("Experience", pInfo[pid][Experience]);
INI_Int("Banned", pInfo[pid][Banned]);
return 1;
}
INI:filename[achievements](name[], value[]) { //code }