29.03.2014, 12:04
First:
It should be like this:
Second Mistake which was causing the password bug
"PASS"(marked in red) should be replaced with "Password", since its the exact field name that's required in cache_get_field_content.
It should be
Since, you're saving your password on register in the field named
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new query[1200], Float:pos[3];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
mysql_format(mysql, query, sizeof(query), "UPDATE `playerdata` SET `Admin`=%d, `VIP`=%d, `Level`=%d, `Rank`=%d,\
`Group`=%d, `posX`=%f, `posY`=%f, `posZ`=%f, `Hours`=%d, `Minutes`=%d, `Respect`=%d, `StreetRespect`=%d,\
`PhoneNummber`=%d, `Money`=%d, WHERE `ID`=%d",\
pInfo[playerid][Admin], pInfo[playerid][VIP], pInfo[playerid][Money], pos[0], pos[1], pos[2],
pInfo[playerid][Rank], pInfo[playerid][Groupid], pInfo[playerid][posX], pInfo[playerid][posY],
pInfo[playerid][posZ], pInfo[playerid][Hours], pInfo[playerid][Minutes],pInfo[playerid][Respect],
pInfo[playerid][StreetRespect], pInfo[playerid][PhoneNummber], pInfo[playerid][ID]);
mysql_tquery(mysql, query, "", "");
return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new query[1200], Float:pos[3];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
mysql_format(mysql, query, sizeof(query), "UPDATE `playerdata` SET `Admin`= '%d' , `VIP`= '%d', `Level`= '%d', `Rank`= '%d', `Group`= '%d', `posX`= '%f', `posY`= '%f', `posZ`= '%f', `Hours`= '%d', `Minutes`= '%d', `Respect`= '%d', `StreetRespect`= '%d', `PhoneNummber`= '%d', `Money`= '%d', WHERE `ID`= '%d'",
pInfo[playerid][Admin], pInfo[playerid][VIP], pInfo[playerid][Money], pos[0], pos[1], pos[2],
pInfo[playerid][Rank], pInfo[playerid][Groupid], pInfo[playerid][posX], pInfo[playerid][posY],
pInfo[playerid][posZ], pInfo[playerid][Hours], pInfo[playerid][Minutes],pInfo[playerid][Respect],
pInfo[playerid][StreetRespect], pInfo[playerid][PhoneNummber], pInfo[playerid][ID]);
mysql_tquery(mysql, query, "", "");
return 1;
}
Quote:
forward OnAccountCheck(playerid); public OnAccountCheck(playerid) { new rows, fields; //a variable that will be used to retrieve rows and fields in the database. cache_get_data(rows, fields, mysql);//let's get the rows and fields from the database. if(rows) //if there is row {//then cache_get_field_content(0, "PASS", pInfo[playerid][Password], mysql, 129); pInfo[playerid][ID] = cache_get_field_content_int(0, "ID"); printf("%s", pInfo[playerid][Password]); ShowPlayerDialog(playerid, dlogin, DIALOG_STYLE_INPUT, "Login", "In order to play, you need to login", "Login", "Quit"); //And since we found a result from the database, which means, there is an account; we will show a login dialog } else { ShowPlayerDialog(playerid, dregister, DIALOG_STYLE_INPUT, "Register", "In order to play, you need to register.", "Register", "Quit"); } return 1; } |
It should be
Quote:
cache_get_field_content(0, "Password", pInfo[playerid][Password], mysql, 129); |
Quote:
mysql_format(mysql, query, sizeof(query), "INSERT INTO `playerdata` (`Username`, `Password`, `IP`, `Admin`, `VIP`, `Level`, `Rank`, `Groupid`, `PosX` ,`PosY`, `PosZ`, `Hours`, `Minutes`, `Respect`, `StreetRespect`, `PhoneNummber`, `Money` ) VALUES ('%e', '%s', '%s', 0, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0)", Name[playerid], pInfo[playerid][Password], IP[playerid]); mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid); |