public LoadUser_data(playerid, name[], value[]) //new function with playerid, player name and value
{
INI_String("Password", PlayerInfo[playerid][Password], 129);
new hashPassword[129];
// WP_Hash(hashPassword,sizeof(hashPassword),inputtext);
WP_Hash(hashPassword, 129, inputtext);
new
uFile[35]; //variable for file
format(uFile, 35, USER_FILE, GetName(playerid));
new
INI:playerFile = INI_Open(uFile);
INI_SetTag(playerFile,"DATA");
INI_WriteString(playerFile, "Password", hashPassword);
new hashPassword[129];
// new inputtext = strval(inputtext);
// WP_Hash(hashPassword,sizeof(hashPassword),inputtext);
// WP_Hash(inputtext,sizeof(inputtext),hashPassword);
WP_Hash(hashPassword, 129, inputtext);
//WP_Hash(wpHash, sizeof(wpHash), inputtext);
if(!strcmp(inputtext,PlayerInfo[playerid][Password]))return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
if(!strcmp(hashPassword, PlayerInfo[playerid][Password], true))
{
//Put what happens when the correct password is filled in.
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
return 0;
}
case DIALOG_LOGIN:
{
if (!response ) return Kick ( playerid );
if( response )
{
// WP_Hash(hashPassword,sizeof(hashPassword),inputtext);
// WP_Hash(inputtext,sizeof(inputtext),hashPassword);
new hashPassword[129],uFile[35];
// WP_Hash(hashPassword, 129, inputtext);
//WP_Hash(wpHash, sizeof(wpHash), inputtext);
WP_Hash(hashPassword,sizeof(hashPassword),inputtext);
printf(hashPassword);
if(!strcmp(hashPassword, PlayerInfo[playerid][Password], true))
{
// if(PlayerInfo[playerid][pBanned]== 1)
// {
// SendClientMessage(playerid, COLOR_YELLOW, "********************************Your account has been banned, please apply on our forums request for unban!*********************************");
// Kick(playerid);
// }
format(uFile, 35, USER_FILE, GetName(playerid));
INI_ParseFile(uFile, "LoadUser_user", .bExtra = true, .extra = playerid);
SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
SetPVarInt(playerid, "Logged", 1);
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
return 0;
}
}
}
case DIALOG_LOGIN:
{
if (!response ) return Kick ( playerid );
if( response )
{
new hashPassword[129];
WP_Hash(hashPassword,sizeof(hashPassword),inputtext);
if(!strcmp(hashPassword, PlayerInfo[playerid][Password]))
{
format(uFile, 35, USER_FILE, GetName(playerid));
INI_ParseFile(uFile, "LoadUser_user", .bExtra = true, .extra = playerid);
SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
SetPVarInt(playerid, "Logged", 1);
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
return 1;
}
}
}
Try like this
pawn Код:
|