08.04.2012, 20:52
(
Последний раз редактировалось Fredden1993; 09.04.2012 в 13:52.
)
There is something wrong with this system. When I register an account and disconnect, re-connects and try to login, it just shows me 'Wrong password'.
Thanks in advance.
pawn Код:
enum pInfo
{
pPassword,
pCash,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
public OnPlayerConnect(playerid)
{
new name[MAX_PLAYER_NAME], file[128];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(file, sizeof(file), "users/%s.ini", name);
if(!fexist(file))
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Register", "Please provide your password below.", "Register", "Cancel"); // this is the dialog type
}
else
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "Please provide your password below.", "Login", "Cancel");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new file[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(file, sizeof(file), "users/%s.ini", name);
if(dini_Exists(file))
{
dini_IntSet(file, "Password", PlayerInfo[playerid][pPassword]);
dini_IntSet(file, "Cash", PlayerInfo[playerid][pCash]);
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1)
{
new file[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(file, sizeof(file), "users/%s.ini", name);
if(response)
{
if(strlen(inputtext))
{
dini_Create(file);
dini_IntSet(file, "Password", num_hash(inputtext));
dini_IntSet(file, "Cash", PlayerInfo[playerid][pCash]);
PlayerInfo[playerid][pCash] = dini_Int(file, "Cash");
}
}
else
{
Kick(playerid);
}
}
if(dialogid == 2)
{
new file[128], name[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(string, sizeof(string), "users/%s.ini", name);
if(response)
{
if(strlen(inputtext))
{
if(num_hash(inputtext) != dini_Int(file, "Password"))
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Wrong password!", "Please provide your password below.", "Login", "Cancel");
}
else
{
PlayerInfo[playerid][pCash] = dini_Int(file, "Cash");
}
}
}
else
{
Kick(playerid);
}
}
return 1;
}