SavePlayer(playerid)
{
if(!PlayerLogged[playerid])
return 0;
UserStats[playerid][moneysave] = GetPlayerMoney(playerid);
new string[512];
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
format(string, sizeof(string), "UPDATE users SET adminlevel='%d',money='%d',kill='%d',death='%d',score='%d',interior='%d' WHERE username='%s'", UserStats[playerid][admin], UserStats[playerid][moneysave], UserStats[playerid][kills], UserStats[playerid][deaths], UserStats[playerid][score], UserStats[playerid][interior], UserStats[playerid][name]);
mysql_query(string);
format(string, sizeof(string), "UPDATE users SET boss='%s',classid='%d',x='%f',y='%f',z='%f',health='%f' WHERE username='%s'", UserStats[playerid][boss], UserStats[playerid][gang], x, y, z, UserStats[playerid][healthsave], UserStats[playerid][name]);
mysql_query(string);
return 1;
}
[MySQL] 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 kill='0',death='0',score='0',interior='0' WHERE username='VirSpector' at line 1.
SavePlayer(playerid)
{
if(!PlayerLogged[playerid])
return 0;
UserStats[playerid][moneysave] = GetPlayerMoney(playerid);
new string[512];
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
format(string, sizeof(string), "UPDATE `users` SET `adminlevel` = '%d', `money` = '%d', `kill` = '%d',`death` = '%d',`score` = '%d',`interior` = '%d' WHERE `username` = '%s'", UserStats[playerid][admin], UserStats[playerid][moneysave], UserStats[playerid][kills], UserStats[playerid][deaths], UserStats[playerid][score], UserStats[playerid][interior], UserStats[playerid][name]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `users` SET `boss` = '%s', `classid` = '%d', `x` = '%f', `y` = '%f', `z` ='%f', `health` = '%f' WHERE `username`= '%s'", UserStats[playerid][boss], UserStats[playerid][gang], x, y, z, UserStats[playerid][healthsave], UserStats[playerid][name]);
mysql_query(string);
return 1;
}
pawn Код:
And use threaded queries. |
public SavePlayerData(playerid)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid])
{
new query[MAX_STRING],string[256];
format(query, MAX_STRING, "UPDATE players SET ");
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `password` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pKey], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
format(string, sizeof(string), "UPDATE `players` SET `Level` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pLevel], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `AdminLevel` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `DonateRank` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pDonateRank], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `PointsUpgrade` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][gPupgrade], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `ConnectedTime` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pConnectTime], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Reg` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pReg], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Sex` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pSex], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Age` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pAge], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Origin` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pOrigin], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `CK` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pCK], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Muted` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pMuted], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Exp` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pExp], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Cash` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pCash], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `AccountBank` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pAccount], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `CrimesComited` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pCrimes], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Kills` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pKills], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Deaths` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Arrested` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pArrested], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `WantedDeaths` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pWantedDeaths], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Phonebook` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPhoneBook], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `LottoNr` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pLottoNr], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Fishes` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pFishes], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `BiggestFish` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pBiggestFish], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Job` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pJob], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `PayCheck` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPayCheck], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `HeadValue` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pHeadValue], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Jailed` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pJailed], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `JailTime` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pJailTime], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Mats` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pMats], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Drugs` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pDrugs], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Leader` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pLeader], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Member` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pMember], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `FMember` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pFMember], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Rank` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pRank], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Char` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pChar], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `ContractTime` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pContractTime], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `DetSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pDetSkill], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `SexSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pSexSkill], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `BoxSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pBoxSkill], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `LawSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPhoneBook], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `MechSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pMechSkill], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `JackSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pJackSkill], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `CarSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pCarSkill], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `NewsSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pNewsSkill], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `DrugsSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pDrugsSkill], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `CookSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pCookSkill], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `FishSkill` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pFishSkill], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `pHealth` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pHealth], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `pSHealth` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pSHealth], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Int` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pInt], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Local` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pLocal], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Team` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pTeam], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Model` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pModel], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Pnumber` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPnumber], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Phousekey` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPhousekey], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Pbiskey` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPbiskey], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
if ((PlayerInfo[playerid][pPos_x]==0.0 && PlayerInfo[playerid][pPos_y]==0.0 && PlayerInfo[playerid][pPos_z]==0.0)) {
PlayerInfo[playerid][pPos_x] = 1684.9;
PlayerInfo[playerid][pPos_y] = -2244.5;
PlayerInfo[playerid][pPos_z] = 13.5;
}
format(string, sizeof(string), "UPDATE `players` SET `Pos_x` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Pos_y` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Pos_z` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPos_z], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `CarLic` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pCarLic], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `FlyLic` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pFlyLic], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `BoatLic` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pBoatLic], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `FishLic` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pFishLic], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `GunLic` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pGunLic], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Gun1` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pGun1], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Gun2` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pGun2], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Gun3` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pGun3], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Gun4` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pGun4], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Ammo1` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pAmmo1], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Ammo2` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pAmmo2], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Ammo3` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pAmmo3], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Ammo4` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pAmmo4], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `CarTime` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pCarTime], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `PayDay` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPayDay], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `PayDayHad` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPayDayHad], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `CDPlayer` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pCDPlayer], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Wins` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pWins], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Loses` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pLoses], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `AlcoholPerk` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pAlcoholPerk], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `DrugPerk` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pDrugPerk], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `MiserPerk` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pMiserPerk], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `PainPerk` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPainPerk], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `TraderPerk` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pTraderPerk], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Tut` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pTut], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `MissionNr` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pMissionNr], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Warns` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pWarns], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Adjustable` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pAdjustable], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Fuel` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pFuel], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `Married` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pMarried], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
format(string, sizeof(string), "UPDATE `players` SET `MarriedTo` = '%s' WHERE `id` = '%d'", PlayerInfo[playerid][pMarriedTo], PlayerInfo[playerid][pSQLID]);
mysql_query(string);
mysql_store_result();
}
}
return 1;
}