MySQL error 2014.
#1

Hello,

Since i modified my saving code yesterday, i get a weird error somehow. It says the syntax that i'm using is wrong, but i dont see the mistake:

Quote:

[18:01:16] CMySQLHandler::Query(UPDATE `users` SET `adminlevel` = '1100', `money` = '10000', `license` = '1', `weaponlicense` = '1', `flylicense` = '1', `job` = '8' WHERE `username` = 'Danny') - An error has occured. (Error ID: 2014, Commands out of sync; you can't run this command now)

And this is the code in the GM:

Код:
	format(file, sizeof file,"UPDATE `users` SET `adminlevel` = '%d', `money` = '%d', `license` = '%d', `weaponlicense` = '%d', `flylicense` = '%d', `job` = '%d' WHERE `username` = '%s'",pInfo[playerid][adminlevel],pInfo[playerid][money],pInfo[playerid][license],pInfo[playerid][weaponlic],pInfo[playerid][flylic],gTeam[playerid],EscapeName);
	mysql_query(file);
	mysql_store_result();
What im doing wrong?

Greetz,
Danny
Reply
#2

pawn Код:
format(file, sizeof file,"UPDATE `users` SET `adminlevel` = '%d', `money` = '%d', `license` = '%d', `weaponlicense` = '%d', `flylicense` = '%d', `job` = '%d' WHERE `username` = '%s'",pInfo[playerid][adminlevel],pInfo[playerid][money],pInfo[playerid][license],pInfo[playerid][weaponlic],pInfo[playerid][flylic],gTeam[playerid],EscapeName);
mysql_query(file);
Reply
#3

I still get this error
Reply
#4

Where u using this code and if can show full
Reply
#5

Yeah, of course:

Код:
public SavePlayerStats(playerid)
{
    new Float:hp;
    new EscapeName[MAX_PLAYER_NAME];
    new Float:am;
    new Float:saveX[MAX_PLAYERS], Float:saveY[MAX_PLAYERS], Float:saveZ[MAX_PLAYERS];
    GetPlayerName(playerid, pname, sizeof (pname));
    GetPlayerIp(playerid, ip, 16);
	GetPlayerHealth(playerid,hp);
	GetPlayerArmour(playerid,am);
	GetPlayerPos(playerid, saveX[playerid], saveY[playerid], saveZ[playerid]);
	pInfo[playerid][money] = GetPlayerMoneyEx(playerid);
	SaveWeaponsToFile(playerid);
	mysql_real_escape_string(pname, EscapeName);
    format(file, sizeof file,"UPDATE `users` SET `adminlevel` = '%d', `money` = '%d', `license` = '%d', `weaponlicense` = '%d', `flylicense` = '%d', `job` = '%d' WHERE `username` = '%s'",pInfo[playerid][adminlevel],pInfo[playerid][money],pInfo[playerid][license],pInfo[playerid][weaponlic],pInfo[playerid][flylic],gTeam[playerid],EscapeName);
	mysql_query(file);
	format(file, sizeof file,"UPDATE `users` SET `faction` = '%d', `rank` = '%d', `skin` = '%d', `health` = '%f', `armour` = '%f', `bankmoney` = '%d', `fightstyle` = '%d', `chainlock` = '%d', `cigarets` = '%d' WHERE `username` = '%s'",pInfo[playerid][faction],pInfo[playerid][rank],pInfo[playerid][skin],floatround(hp),floatround(am),pInfo[playerid][bankmoney],pInfo[playerid][fightstyle],pInfo[playerid][chainlock],pInfo[playerid][cigarets],EscapeName);
	mysql_query(file);
	mysql_store_result();
	format(file, sizeof file,"UPDATE `users` SET `beer` = '%d', `sprunk` = '%d', `weed` = '%d', `seeds` = '%d', `prepaid` = '%d', `jerrycan` = '%d', `cellphone` = '%d', `phonenum` = '%d', `dlock` = '%d' WHERE `username` = '%s'",pInfo[playerid][beer],pInfo[playerid][sprunk],pInfo[playerid][weed],pInfo[playerid][seeds],pInfo[playerid][prepaid],pInfo[playerid][jerrycan],pInfo[playerid][havephone],pInfo[playerid][phonenum],pInfo[playerid][dlock],EscapeName);
	mysql_query(file);
	mysql_store_result();
	format(file, sizeof file,"UPDATE `users` SET `cellphone` = '%d', `weed` = '%d', `seeds` = '%d', `jerrycan` = '%d', `prepaid` = '%d', `dlock` = '%d' WHERE `username` = '%s'",pInfo[playerid][havephone],pInfo[playerid][weed],pInfo[playerid][seeds],pInfo[playerid][jerrycan],pInfo[playerid][prepaid],pInfo[playerid][dlock],EscapeName);
	mysql_query(file);
	mysql_store_result();
	format(file, sizeof file,"UPDATE `users` SET `gps` = '%d', `warns` = '%d', `vip` = '%d', `kills` = '%d', `deaths` = '%d', `spawnX` = '%f', `spawnY` = '%f', `spawnZ` = '%f' WHERE `username` = '%s'",pInfo[playerid][GPS],pInfo[playerid][warns],pInfo[playerid][VIP],pInfo[playerid][kills],pInfo[playerid][deaths],saveX[playerid],saveY[playerid],saveZ[playerid],EscapeName);
    mysql_query(file);
	mysql_free_result();
	format(file, sizeof file,"UPDATE `users` SET `jailedtime` = '%d', `ajailedtime` = '%d' WHERE `username` = '%s'",JailEndTime[playerid]-GetTickCount(),JailEndTime[playerid]-GetTickCount(),EscapeName);
	mysql_query(file);
	mysql_free_result();
}
Reply
#6

You called this function when player disconnect from server yes?

Also you need remove:

mysql_store_result(); and mysql_free_result();
Reply
#7

Yes, it's called when a player disconnects.
Reply
#8

pawn Код:
public SavePlayerStats(playerid)
{
    new Float:hp;
    new EscapeName[MAX_PLAYER_NAME];
    new Float:am;
    new Float:saveX[MAX_PLAYERS], Float:saveY[MAX_PLAYERS], Float:saveZ[MAX_PLAYERS];
    GetPlayerName(playerid, pname, sizeof (pname));
    GetPlayerIp(playerid, ip, 16);
    GetPlayerHealth(playerid,hp);
    GetPlayerArmour(playerid,am);
    GetPlayerPos(playerid, saveX[playerid], saveY[playerid], saveZ[playerid]);
    pInfo[playerid][money] = GetPlayerMoneyEx(playerid);
    SaveWeaponsToFile(playerid);
    mysql_real_escape_string(pname, EscapeName);
    format(file, sizeof file,"UPDATE `users` SET `adminlevel` = '%d', `money` = '%d', `license` = '%d', `weaponlicense` = '%d', `flylicense` = '%d', `job` = '%d' WHERE `username` = '%s'",pInfo[playerid][adminlevel],pInfo[playerid][money],pInfo[playerid][license],pInfo[playerid][weaponlic],pInfo[playerid][flylic],gTeam[playerid],EscapeName);
    mysql_query(file);
    format(file, sizeof file,"UPDATE `users` SET `faction` = '%d', `rank` = '%d', `skin` = '%d', `health` = '%f', `armour` = '%f', `bankmoney` = '%d', `fightstyle` = '%d', `chainlock` = '%d', `cigarets` = '%d' WHERE `username` = '%s'",pInfo[playerid][faction],pInfo[playerid][rank],pInfo[playerid][skin],floatround(hp),floatround(am),pInfo[playerid][bankmoney],pInfo[playerid][fightstyle],pInfo[playerid][chainlock],pInfo[playerid][cigarets],EscapeName);
    mysql_query(file);
    format(file, sizeof file,"UPDATE `users` SET `beer` = '%d', `sprunk` = '%d', `weed` = '%d', `seeds` = '%d', `prepaid` = '%d', `jerrycan` = '%d', `cellphone` = '%d', `phonenum` = '%d', `dlock` = '%d' WHERE `username` = '%s'",pInfo[playerid][beer],pInfo[playerid][sprunk],pInfo[playerid][weed],pInfo[playerid][seeds],pInfo[playerid][prepaid],pInfo[playerid][jerrycan],pInfo[playerid][havephone],pInfo[playerid][phonenum],pInfo[playerid][dlock],EscapeName);
    mysql_query(file);
    format(file, sizeof file,"UPDATE `users` SET `cellphone` = '%d', `weed` = '%d', `seeds` = '%d', `jerrycan` = '%d', `prepaid` = '%d', `dlock` = '%d' WHERE `username` = '%s'",pInfo[playerid][havephone],pInfo[playerid][weed],pInfo[playerid][seeds],pInfo[playerid][jerrycan],pInfo[playerid][prepaid],pInfo[playerid][dlock],EscapeName);
    mysql_query(file);
    format(file, sizeof file,"UPDATE `users` SET `gps` = '%d', `warns` = '%d', `vip` = '%d', `kills` = '%d', `deaths` = '%d', `spawnX` = '%f', `spawnY` = '%f', `spawnZ` = '%f' WHERE `username` = '%s'",pInfo[playerid][GPS],pInfo[playerid][warns],pInfo[playerid][VIP],pInfo[playerid][kills],pInfo[playerid][deaths],saveX[playerid],saveY[playerid],saveZ[playerid],EscapeName);
    mysql_query(file);
    format(file, sizeof file,"UPDATE `users` SET `jailedtime` = '%d', `ajailedtime` = '%d' WHERE `username` = '%s'",JailEndTime[playerid]-GetTickCount(),JailEndTime[playerid]-GetTickCount(),EscapeName);
    mysql_query(file);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)