MYSQL Problems.... R38.
#4

First:
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;
}
It should be like this:
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;
}
Second Mistake which was causing the password bug

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;
}

"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
Quote:

cache_get_field_content(0, "Password", pInfo[playerid][Password], mysql, 129);

Since, you're saving your password on register in the field named
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);

Reply


Messages In This Thread
MYSQL Problems.... R38. - by Scrillex - 29.03.2014, 10:47
Re: MYSQL Problems.... R38. - by sarab_singh - 29.03.2014, 11:35
Re: MYSQL Problems.... R38. - by Scrillex - 29.03.2014, 11:51
Re: MYSQL Problems.... R38. - by iBeast - 29.03.2014, 12:04

Forum Jump:


Users browsing this thread: 1 Guest(s)