pawn Code:
forward LoadUser_data(playerid, name[], value[]);
public LoadUser_data(playerid, name[], value[])
{
INI_String("Name", pInfo[playerid][pName]);
INI_String("Password", pInfo[playerid][pPass]);
INI_String("Salt", pInfo[playerid][pSalt]);
INI_Int("Money", pInfo[playerid][pMoney]);
INI_Int("Score", pInfo[playerid][pScore]);
INI_Int("Kills", pInfo[playerid][pKills]);
INI_Int("Deaths", pInfo[playerid][pDeaths]);
INI_Int("Admin", pInfo[playerid][pAdmin]);
return 1;
}
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),USER_PATH,playername);
return string;
}
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "MC:RP - Accesso Utente", "Bentornato!\nQuesto account e' gia' registrato.\nDigita la tua password per accedere.", "Accedi", "Esci");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "MC:RP - Registrazione Utente", "Benvenuto!\nQuesto account non e' registrato.\nDigita una password per registrarti.", "Registra", "Esci");
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_REGISTER:
{
if(!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext))
{
SendClientMessage(playerid, COLOR_RED, "[ERRORE]: Devi digitare una password per poterti registrare!");
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "MC:RP - Registrazione Utente", "Benvenuto!\nQuesto account non e' registrato.\nDigita una password per registrarti.", "Registra", "Esci");
}
new salt[11];
for(new i; i < 10; i++)
{
salt[i] = random(79) + 47;
}
salt[10] = 0;
SHA256_PassHash(inputtext, salt, pInfo[playerid][pPass], 65);
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File, "Player's Data");
INI_WriteString(File, "Name", Name);
INI_WriteString(File, "Password", pInfo[playerid][pPass]);
INI_WriteString(File, "Salt", salt);
INI_WriteInt(File, "Money", 0);
INI_WriteInt(File, "Score", 0);
INI_WriteInt(File, "Kills", 0);
INI_WriteInt(File, "Deaths", 0);
INI_WriteInt(File, "Admin", 0);
INI_Close(File);
}
return 1;
}
case DIALOG_LOGIN:
{
if(!response) return Kick(playerid);
if(response)
{
new hash[65];
SHA256_PassHash(inputtext, pInfo[playerid][pSalt], hash, 64);
if(!strcmp(hash, pInfo[playerid][pPass]))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, pInfo[playerid][pMoney]);
}
else
{
SendClientMessage(playerid, COLOR_RED, "[ERRORE]: Hai digitato una password errata. Riprova!");
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "MC:RP - Accesso Utente", "Bentornato!\nQuesto account e' gia' registrato.\nDigita la tua password per accedere.", "Accedi", "Esci");
}
return 1;
}
}
}
return 1;
}
Why I can't login? What's wrong? It saves everything but I can't access.