When I try to login, the server tells me the password is wrong. What's wrong ?
PHP код:
if(dialogid == REGISTER)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, REGISTER, DIALOG_STYLE_PASSWORD, "{FFFF00}Inregistrare", "{FF0000}Trebuie sa va inregistrati", "Register", "Inchide");
if(!response) return Kick(playerid);
if(response)
{
new INI:File = INI_Open(User(playerid));
INI_WriteInt(File, "Password", udb_hash(inputtext));
INI_Close(File);
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
SendClientMessage(playerid, 0x00FF00FF, "Te-ai inregistrat cu succes !");
new String[256], Name[MAX_PLAYER_NAME], dd, mm, yy, h, m;
GetPlayerName(playerid, Name, sizeof(Name));
getdate(yy, mm, dd);
gettime(h, m);
format(String, sizeof(String), "{FFFFFF}Nume: {FFFF00}%s\n{FFFFFF}Data: {FFFF00}%02d/%02d/%02d\n{FFFFFF}Ora: {00FF00}%02d:%02d\n{FFFFFF}Parola: {FFFF00}%s\n{00773C}Apasa butonul 'F8' pentru a face o captura a ecranului.", Name, dd, mm, yy, h, m, inputtext);
ShowPlayerDialog(playerid, 11, DIALOG_STYLE_MSGBOX, "{00FF00}Informatii inregistrare.", String, "Ok", "");
DestroyRegistrationMenu(playerid);
}
}
if(dialogid == LOGIN)
{
if(!response) return Kick(playerid);
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "{FF0000}Conectare", "{FF0000}Trebuie sa te conectezi.", "Connect", "Iesire");
if(response)
{
INI_ParseFile(User(playerid), "PlayerData_Data", .bExtra = true, .extra = playerid);
if(udb_hash(inputtext) == pInfo[playerid][Pass])
{
SpawnPlayer(playerid);
SetPlayerPos(playerid, pInfo[playerid][x], pInfo[playerid][y], pInfo[playerid][z]);
SetPlayerFacingAngle(playerid, pInfo[playerid][a]);
GivePlayerMoney(playerid, pInfo[playerid][Cash]);
SetPlayerScore(playerid, pInfo[playerid][Score]);
pInfo[playerid][Kills] = pInfo[playerid][Kills];
pInfo[playerid][Deaths] = pInfo[playerid][Deaths];
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
SendClientMessage(playerid, 0x00FF00FF, "Ai fost conectat pe server cu succes.");
DestroyRegistrationMenu(playerid);
}
else
{
if(Attempts[playerid] <= 2)
{
PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
Attempts[playerid] ++;
new String[128];
format(String, sizeof(String), "{FF0000}Parola gresita {FFFF00}%d/3 {FFFFFF}incercari.", Attempts[playerid]);
ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "{FF0000}Conectare", String, "Connect", "Iesire");
}
if(Attempts[playerid] == 3)
{
PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
ShowPlayerDialog(playerid, 12, DIALOG_STYLE_MSGBOX, "{FF0000}Conectare epuizata", "{FF0000}Ai fost dat afara pentru ca ai gresit parola de conectare de 3 ori.", "Am inteles.", "");
SetTimerEx("KickForBadLogin", 500, false, "i", playerid);
DestroyRegistrationMenu(playerid);
}
}
}
}
PHP код:
public PlayerData_Data(playerid, name[], value[])
{
INI_Int("Password", pInfo[playerid][Pass]);
INI_Float("X", pInfo[playerid][x]);
INI_Float("Y", pInfo[playerid][y]);
INI_Float("Z", pInfo[playerid][z]);
INI_Float("A", pInfo[playerid][a]);
INI_Int("Cash", pInfo[playerid][Cash]);
INI_Int("Score", pInfo[playerid][Score]);
INI_Int("Kills", pInfo[playerid][Kills]);
INI_Int("Deaths", pInfo[playerid][Deaths]);
return 1;
}
Before trying to fix that problem, I would recommend to change your hashing method to Whirlpool. udb_hash can be cracked easily, use Whirlpool WITH salts in order to make the data (actually, OUR data) safe.
After you switch to a recommended hash method, I would suggest you to start debugging the script to find where the authentication problem is.
Thank's for the info but for the moment is perfectly this method. I'm not pro in pawno but i want to learn. Learn with this community and wiki.
And make sure to write everything under the [Data] tag.
Or else, you can remove all of the tags, and load the whole file under one callback.