SA-MP Forums Archive
MYSQL Saving problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MYSQL Saving problem (/showthread.php?tid=575837)



MYSQL Saving problem - McGuiness - 30.05.2015

Hey so I was testing my saving system but its saving the password but nothing else and I get a feeling its because of the players personal car info, heres the save player part (which shows the vehicles part):

pawn Код:
format(Query, sizeof(Query), "UPDATE `playerdata` SET `Cash` = '%d', `Admin` = '%d', `Kills` = '%d', `Deaths` = '%d', `Age` = '%d', `Skin` = '%d', `PosX` = '%f', `PosY` = '%f', `PosZ` = '%f', `Angle` = '%f', `Gender` = '%d', `Faction` = '%d', `Rank` = '%d', `Leader` = '%d' WHERE `nick` = '%s' LIMIT 1",
    GetPlayerMoney(playerid),
    PlayerInfo[playerid][pCash],
    PlayerInfo[playerid][pAdmin],
    PlayerInfo[playerid][pKills],
    PlayerInfo[playerid][pDeaths],
    PlayerInfo[playerid][pAge],
    PlayerInfo[playerid][pSkin],
    PlayerInfo[playerid][PosX],
    PlayerInfo[playerid][PosY],
    PlayerInfo[playerid][PosZ],
    PlayerInfo[playerid][Angle],
    PlayerInfo[playerid][pGender],
    PlayerInfo[playerid][pFaction],
    PlayerInfo[playerid][fRank],
    PlayerInfo[playerid][fLeader]);
    mysql_query(Query);
   
    format(Query, sizeof(Query), "UPDATE `playerdata` SET `Division` = '%d', `DivLeader` = '%d', `BadgeNum` = '%d', `Gang` = '%d', `gRank` = '%d', `Crack` = '%d', `Weed` = '%d', `Meth` = '%d', `VIP` = '%d', `Materials` = '%d', `HouseOwner` = '%d', `BizID` = '%d', `Vehicle1` = '%d', `Vehicle1Model` = '%d' WHERE `nick` = '%s' LIMIT 1",
    PlayerInfo[playerid][fDivision],
    PlayerInfo[playerid][fDivLeader],
    PlayerInfo[playerid][fBadgeNum],
    PlayerInfo[playerid][pGang],
    PlayerInfo[playerid][gRank],
    PlayerInfo[playerid][pCrack],
    PlayerInfo[playerid][pWeed],
    PlayerInfo[playerid][pMeth],
    PlayerInfo[playerid][pVIP],
    PlayerInfo[playerid][pMaterials],
    PlayerInfo[playerid][HouseOwner],
    PlayerInfo[playerid][BizID],
    PlayerInfo[playerid][pVehicle1],
    PlayerInfo[playerid][pVehicle1Model]);
    mysql_query(Query);
   
    format(Query, sizeof(Query), "UPDATE `playerdata` SET `Vehicle1X` = '%f, `Vehicle1Y` = '%f', `Vehicle1Z` = '%f', `Vehicle1C` = '%f', `Vehicle1Color1` = '%d', `Vehicle1Color2` = '%d', `Vehicle1Value` = '%d', `Vehicle1Plate` = '%s', `Vehicle1Lock` = '%d', `Vehicle2` = '%d', `Vehicle2Model` = '%d', `Vehicle2X` = '%f', `Vehicle2Y` = '%f', `Vehicle2Z` = '%f' WHERE `nick` = '%s' LIMIT 1",
    PlayerInfo[playerid][pVehicle1X],
    PlayerInfo[playerid][pVehicle1Y],
    PlayerInfo[playerid][pVehicle1Z],
    PlayerInfo[playerid][pVehicle1C],
    PlayerInfo[playerid][pVehicle1Color1],
    PlayerInfo[playerid][pVehicle1Color2],
    PlayerInfo[playerid][pVehicle1Value],
    PlayerInfo[playerid][pVehicle1Plate],
    PlayerInfo[playerid][pVehicle1Lock],
    PlayerInfo[playerid][pVehicle2],
    PlayerInfo[playerid][pVehicle2Model],
    PlayerInfo[playerid][pVehicle2X],
    PlayerInfo[playerid][pVehicle2Y],
    PlayerInfo[playerid][pVehicle2Z]);
    mysql_query(Query);
   
    format(Query, sizeof(Query), "UPDATE `playerdata` SET `Vehicle2C` = '%f', `Vehicle2Color1` = '%d', `Vehicle2Color2` = '%d', `Vehicle2Value` = '%d', `Vehicle2Plate` = '%s', `Vehicle2Lock` = '%d', `Vehicle3` = '%d', `Vehicle3Model` = '%d', `Vehicle3X` = '%f', `Vehicle3Y` = '%f', `Vehicle3Z` = '%f', `Vehicle3C` = '%f', `Vehicle3Color1` = '%d', `Vehicle3Color2` = '%d' WHERE `nick` = '%s' LIMIT 1",
    PlayerInfo[playerid][pVehicle2C],
    PlayerInfo[playerid][pVehicle2Color1],
    PlayerInfo[playerid][pVehicle2Color2],
    PlayerInfo[playerid][pVehicle2Value],
    PlayerInfo[playerid][pVehicle2Plate],
    PlayerInfo[playerid][pVehicle2Lock],
    PlayerInfo[playerid][pVehicle3],
    PlayerInfo[playerid][pVehicle3Model],
    PlayerInfo[playerid][pVehicle3X],
    PlayerInfo[playerid][pVehicle3Y],
    PlayerInfo[playerid][pVehicle3Z],
    PlayerInfo[playerid][pVehicle3C],
    PlayerInfo[playerid][pVehicle3Color1],
    PlayerInfo[playerid][pVehicle3Color2]);
    mysql_query(Query);
   
    format(Query, sizeof(Query), "UPDATE `playerdata` SET `Vehicle3Value` = '%d', `Vehicle3Plate` = '%s', `Vehicle3Lock` = '%d', `Job` = '%d', `Weapon1` = '%d', `Weapon1a` = '%d', `Weapon2` = '%d', `Weapon2a` = '%d', `Weapon3` = '%d', `Weapon3a` = '%d', `Weapon4` = '%d', `Weapon4a` = '%d', `Weapon5` = '%d', `Weapon5a` = '%d' WHERE `nick` = '%d' LIMIT 1",
    PlayerInfo[playerid][pVehicle3Value],
    PlayerInfo[playerid][pVehicle3Plate],
    PlayerInfo[playerid][pVehicle3Lock],
    PlayerInfo[playerid][pJob],
    PlayerInfo[playerid][Weapon1],
    PlayerInfo[playerid][Weapon1a],
    PlayerInfo[playerid][Weapon2],
    PlayerInfo[playerid][Weapon2a],
    PlayerInfo[playerid][Weapon3],
    PlayerInfo[playerid][Weapon3a],
    PlayerInfo[playerid][Weapon4],
    PlayerInfo[playerid][Weapon4a],
    PlayerInfo[playerid][Weapon5],
    PlayerInfo[playerid][Weapon5a]);
    mysql_query(Query);
and heres the MySQL error I get:
Код:
[Sat May 30 15:03:33 2015] Error (0): Failed to exeute query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0.000000', `Vehicle1Z` = '0.000000', `Vehicle1C` = '0.000000', `Vehicle1Color1` ' at line 1.
Any ideas why this is happening as its never happened to me before...


Re: MYSQL Saving problem - DevaBeast - 30.05.2015

Your problem is ' '.

Try:

format(string, sizeof(string), "UPDATE playerdata SET Division = %d WHERE Name = '%s'", pInfo[playerid][pDivision], name)

You can to put ' ' just for strings, example: '%s'. Also, is wrong to put ' ' for numbers, right is: %d.

I had same trouble, but I solved it.

Sorry for my English, I know a little.

Have a nice day!