23.04.2017, 02:10
http://i.imgur.com/UPRY7L0.png
^
Here is a link to the mySQL error log.
Explanation: I can register on the server and everything will be perfect. No issues. However, When I log out and log back in I begin falling from the sky and I put some debug comments in the script and I found out that my [pSQLID] = 0 so it isn't loading any of the proper information for that specific account. The username and password to log in works fine, But it seems the issue is I'm not assigning the [pSQLID] to the player data during the login process. Or that may just be a result of a bigger issue. Let me just link you my code.
I would really appreciate if you could spare a few minutes to help me solve my issues.
Thanks again, I appreciate any help.
^
Here is a link to the mySQL error log.
Explanation: I can register on the server and everything will be perfect. No issues. However, When I log out and log back in I begin falling from the sky and I put some debug comments in the script and I found out that my [pSQLID] = 0 so it isn't loading any of the proper information for that specific account. The username and password to log in works fine, But it seems the issue is I'm not assigning the [pSQLID] to the player data during the login process. Or that may just be a result of a bigger issue. Let me just link you my code.
PHP код:
case DIALOG_LOGIN:
{
if(!response) return Kick(playerid);
if(strlen(inputtext) < 3 || strlen(inputtext) > 30) {
ShowLoginDialog(playerid, "Password length must be at least 3 characters and below 30 characters.");
return true;
}
new query[128];
mysql_format(sqlConnection, query, sizeof(query), "SELECT id FROM players WHERE Name = '%e' AND Password = sha1('%e') LIMIT 1", GetName(playerid), inputtext);
mysql_pquery(sqlConnection, query, "SQL_OnAccountLogin", "i", playerid);
}
PHP код:
Server:SQL_OnAccountLogin(playerid)
{
if(cache_num_rows() == 0){
ShowLoginDialog(playerid, "Incorrect Password.");
return true;
}
SendClientMessage(playerid, COLOR_WHITE, "You have successfully logged in.");
//debug
new string[128];
format(string, sizeof(string), "* Your SQL id is: %i", PlayerData[playerid][pSQLID]);
SendClientMessage(playerid, COLOR_WHITE, string);
//debug end
LoadPlayerData(playerid);
return true;
}
PHP код:
Server: SQL_OnLoadAccount(playerid)
{
LoggedIn[playerid] = true;
PlayerData[playerid][pSQLID] = cache_get_field_content_int(0, "id", sqlConnection);
PlayerData[playerid][pAdminLevel] = cache_get_field_content_int(0, "AdminLevel", sqlConnection);
PlayerData[playerid][pMoney] = cache_get_field_content_int(0, "Money", sqlConnection);
PlayerData[playerid][pLevel] = cache_get_field_content_int(0, "Level", sqlConnection);
PlayerData[playerid][pRespect] = cache_get_field_content_int(0, "Respect", sqlConnection);
PlayerData[playerid][pLastPos][0] = cache_get_field_content_float(0, "LastX", sqlConnection);
PlayerData[playerid][pLastPos][1] = cache_get_field_content_float(0, "LastY", sqlConnection);
PlayerData[playerid][pLastPos][2] = cache_get_field_content_float(0, "LastZ", sqlConnection);
PlayerData[playerid][pLastPos][3] = cache_get_field_content_float(0, "LastRot", sqlConnection);
PlayerData[playerid][pLastInt] = cache_get_field_content_int(0, "Interior", sqlConnection);
PlayerData[playerid][pLastWorld] = cache_get_field_content_int(0, "World", sqlConnection);
SetPlayerScore(playerid, PlayerData[playerid][pLevel]);
ResetPlayerMoney(playerid); GivePlayerMoney(playerid, PlayerData[playerid][pMoney]);
SetPlayerSpawn(playerid);
return true;
}
PHP код:
Server:LoadPlayerData(playerid)
{
new query[255];
mysql_format(sqlConnection, query, sizeof(query), "SELECT * FROM players WHERE id = %i LIMIT 1", PlayerData[playerid][pSQLID]);
mysql_pquery(sqlConnection, query, "SQL_OnLoadAccount", "i", playerid);
return true;
}
Thanks again, I appreciate any help.