27.04.2015, 23:23
Actually i'm trying to hash player password's the problem is sometimes it doesn't work good, i mean when trying to login it says wrong password, when player's register it works fine..
Here's my codes.
PlayerConnected(playerid); >> it checks the player if he's banned , and it will spawn his info
What's wrong with my codes, please answer as soon as possible
EDIT: Uhhh lol the first time i connect with my account it works good.. when i re connect it doesn't it says wrong password
Here's my codes.
Код:
case D_REGISTER: { if (response) { if(strlen(inputtext) > 18) { SendInfoMessage(playerid, 0, "8", "Password must be a maximum of 18 characters."); ShowRegisterDialog(playerid,D_REGISTER); return 1; } if(IsNull(inputtext)) { ShowRegisterDialog(playerid,D_REGISTER); return 1; } new hashpass[129],PlayerFile[64], playername3[MAX_PLAYER_NAME]; GetPlayerName(playerid, playername3, sizeof(playername3)); format(PlayerFile, sizeof(PlayerFile), "Accounts/%s.ini", playername3); new INI:PlayerAcc = INI_Open( PlayerFile ); WP_Hash(hashpass,sizeof(hashpass),inputtext); INI_WriteString(PlayerAcc,"Password",hashpass); INI_Close(PlayerAcc); Dialog(playerid,D_LOGIN,DIALOG_STYLE_PASSWORD,"{00FF6E}Log in","{F0F0F0}For security reasons, confirm your password:","Confirm","Cancel"); } else { Kick(playerid); } return 1; }
Код:
case D_LOGIN: { if (response) { if(IsNull(inputtext)) { ShowLoginDialog(playerid,D_INGRESO); return 1; } new string2[128], hashpass[129], playername2[MAX_PLAYER_NAME]; INI_ParseFile(string2, "GetPlayerPass", .bExtra = true, .extra = playerid); GetPVarString(playerid, "Password", hashpass, 32); WP_Hash(hashpass,sizeof(hashpass),inputtext); if(!strcmp(hashpass, PlayerInfo[playerid][pPassword], false)) { GetPlayerName(playerid, playername2, sizeof(playername2)); format(string2, sizeof(string2), "Accounts/%s.ini", playername2); INI_ParseFile(string2, "Character_Info", false, true, playerid, true, false ); format(string2, sizeof(string2), "PlayersVehicles/%s.ini", playername2); INI_ParseFile(string2, "Vehicle_Info", false, true, playerid, true, false ); format(string2, sizeof(string2), "PlayersToys/%s.ini", playername2); INI_ParseFile(string2, "Toys_Info", false, true, playerid, true, false ); PlayerConnected(playerid); } else { ClearChatbox(playerid); ShowLoginDialog(playerid,D_LOGIN); SendInfoMessage(playerid, 0, "7", "The typed password is not valid, please try again."); gPlayerLogTries[playerid] += 1; if(gPlayerLogTries[playerid] == 3) { Kick(playerid); } } } else { Kick(playerid); } return 1; }
What's wrong with my codes, please answer as soon as possible
EDIT: Uhhh lol the first time i connect with my account it works good.. when i re connect it doesn't it says wrong password