14.08.2018, 11:32
Hi
Everytime I close the server and load it again, and then attempt to log back into the account I just made - it does not let me pass the dialog box to log in. I am not sure whats happening. It makes it so that I have to keep deleting accounts from the database instead of keeping them
Here is my playercheck code:
Here is my dialog_login (both dialogs
Everytime I close the server and load it again, and then attempt to log back into the account I just made - it does not let me pass the dialog box to log in. I am not sure whats happening. It makes it so that I have to keep deleting accounts from the database instead of keeping them
Here is my playercheck code:
PHP Code:
forward OnPlayerDataCheck(playerid, corrupt_check);
public OnPlayerDataCheck(playerid, corrupt_check)
{
if (corrupt_check != Corrupt_Check[playerid]) return Kick(playerid);
new string[150], rows;
cache_get_row_count(rows);
if(rows)
{
cache_get_value(0, "playerPass", playerInfo[playerid][playerPass],65);
playerInfo[playerid][Player_Cache] = cache_save();
format(string, sizeof(string), "{FFFFFF}Welcome back, %s.\n{0099FF}You're already registered. Log in to the server below.", playerInfo[playerid][playerName]);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login to the server", string, "Login", "Leave");
}
else
{
format(string, sizeof(string), "{FFFFFF}Welcome %s. to County-Side Roleplay\n\n{0099FF}You're not registered. Input a password to begin.", playerInfo[playerid][playerName]);
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registration to the server", string, "Register", "Leave");
}
return 1;
}
PHP Code:
case DIALOG_LOGIN:
{
new Salted_Key[65];
if(!response) return Kick(playerid);
SHA256_PassHash(inputtext, playerInfo[playerid][Salt], Salted_Key, 65);
new string[128];
format(string, sizeof(string), "{FFFFFF}Welcome back, %s.\n{0099FF}You're already registered. Log in to the server below.", playerInfo[playerid][playerName]);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login to the server", string, "Login", "Leave");
if(strcmp(Salted_Key, playerInfo[playerid][playerPass]) == 0)
{
cache_set_active(playerInfo[playerid][Player_Cache]);
cache_delete(playerInfo[playerid][Player_Cache]);
playerInfo[playerid][Player_Cache] = MYSQL_INVALID_CACHE;
playerInfo[playerid][LoggedIn] = true;
new DB_Query[225];
print(DB_Query);
ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Login", "You have been successfully logged in.", "Okay", "");
mysql_format(Database, DB_Query, sizeof(DB_Query), "SELECT * FROM `accounts` WHERE `playerName` = '%s' LIMIT 1", playerInfo[playerid][playerName]);
mysql_tquery(Database, DB_Query, "LoadPlayerStats", "i", playerid);
TextDrawHideForPlayer(playerid, countyside);
TextDrawHideForPlayer(playerid, roleplay);
TextDrawHideForPlayer(playerid, BOX);
TextDrawHideForPlayer(playerid, outline1);
TextDrawHideForPlayer(playerid, outline2);
//SendClientMessage(playerid, 0x00FF00FF, "SERVER: {FFFFFF} You've just logged into this account.");
}
}
case DIALOG_REGISTER:
{
new string[128];
if(!response) return Kick(playerid);
format(string, sizeof(string), "{FFFFFF}Welcome %s. to County-Side Roleplay\n\n{0099FF}You're not registered. Input a password to begin.", playerInfo[playerid][playerName]);
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registration to the server", string, "Register", "Leave");
if(strlen(inputtext) <= 5 || strlen(inputtext) > 60)
return SendClientMessage(playerid, 0x969696FF, "Invalid password length, should be 5 - 60.");
for (new i = 0; i < 16; i++) playerInfo[playerid][Salt][i] = random(94) + 33;
SHA256_PassHash(inputtext, playerInfo[playerid][Salt], playerInfo[playerid][playerPass], 65);
new DB_Query[225];
mysql_format(Database, DB_Query, sizeof DB_Query, "INSERT INTO `accounts` (`playerName`, `playerPass`, `salt`) VALUES ('%e', '%s', '%e')", playerInfo[playerid][playerName], playerInfo[playerid][playerPass], playerInfo[playerid][Salt]);
mysql_tquery(Database, DB_Query, "OnPlayerRegister", "d", playerid);
SetPlayerScore(playerid, 1);
TextDrawHideForPlayer(playerid, countyside);
TextDrawHideForPlayer(playerid, roleplay);
TextDrawHideForPlayer(playerid, BOX);
TextDrawHideForPlayer(playerid, outline1);
TextDrawHideForPlayer(playerid, outline2);
}
}