I'm having issue's relogging. I can register an account successfully of course, but if I quit the server and reconnect, when it asks for my password I can't seem to log in. I also have an admin control panel set up on my website that can't log in either, when all was well before. I don't remember what I changed, my mind is fried.
PHP Code:
stock RegisterPlayer(playerid, regpass[])
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
new query[256];
new EncryptedPass[130];
WP_Hash(EncryptedPass, sizeof(EncryptedPass), regpass);
format(query, sizeof(query), "INSERT INTO user_accounts (Username, Password, PlayerPos, Skin) VALUES ('%s', '%s', '1.0 2.0 3.0', '0')", pName, EncryptedPass);
mysql_query(query);
LoginPlayer(playerid);
return 1;
}
stock LoginPlayer(playerid)
{
new query[126];
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(query, sizeof(query), "SELECT * FROM user_accounts WHERE Username = '%s'", pName);
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query, "|"))
{
mysql_fetch_field_row(Player[playerid][Username], "Username");
mysql_fetch_field_row(Player[playerid][Password], "Password");
mysql_fetch_field_row(query, "PlayerPos"); sscanf(query, "fff", Player[playerid][Position][0], Player[playerid][Position][1], Player[playerid][Position][2]);
mysql_fetch_field_row(query, "AdminLevel"); Player[playerid][AdminLevel] = strval(query);
mysql_fetch_field_row(query, "Skin"); Player[playerid][Skin] = strval(query);
mysql_fetch_field_row(query, "LoggedIn"); Player[playerid][LoggedIn] = strval(query);
mysql_fetch_field_row(query, "Money"); Player[playerid][Money] = strval(query);
mysql_fetch_field_row(query, "ID"); Player[playerid][ID] = strval(query);
}
GivePlayerMoney(playerid, Player[playerid][Money]);
LogIn(pName);
}
stock SavePlayer(playerid)
{
new query[1024];
new EncryptedPass[130];
WP_Hash(EncryptedPass, sizeof(EncryptedPass), Player[playerid][Password]);
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
Player[playerid][Money] = GetPlayerMoney(playerid);
Player[playerid][Skin] = GetPlayerSkin(playerid);
GetPlayerPos(playerid, Player[playerid][Position][0], Player[playerid][Position][1], Player[playerid][Position][2]);
format(query, sizeof(query), "UPDATE user_accounts SET Username = '%s', Password = '%s', PlayerPos = '%f %f %f', AdminLevel = '%d', Skin = '%d', Money = '%d' WHERE Username = '%s'", pName, EncryptedPass, Player[playerid][Position][0], Player[playerid][Position][1], Player[playerid][Position][2], Player[playerid][AdminLevel], Player[playerid][Skin], Player[playerid][Money], pName);
mysql_query(query);
printf("Player ID %d (%s) has been updated", playerid, pName);
}
PHP Code:
case dialogThreadLogin:
{
if(response)
{
new query[256];
new EncryptedPass[130];
WP_Hash(EncryptedPass, sizeof(EncryptedPass), inputtext);
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(query, sizeof(query), "SELECT * FROM user_accounts WHERE Username = '%s' AND Password = '%s'", pName, EncryptedPass);
mysql_query(query);
mysql_store_result();
if(mysql_num_rows() == 1)
{
LoginPlayer(playerid);
} else {
SendClientMessage(playerid, -1, "Incorrect password.");
ShowPlayerDialog(playerid, dialogThreadLogin, DIALOG_STYLE_INPUT, "Login", "Enter your password:", "Login", "Cancel");
}
}
}
Aucun commentaire:
Enregistrer un commentaire