MySQL issue
#1

Okay..
I get this error everytime i buy a vehicle.
Quote:

mysql_tquery - callback parameter count does not match format specifier length

Everytime i buy a vehicle it wont save the vehicle in my mysql table and it gives me a bug. Which says i got 1 vehicle but it dosent show the stats of the vehicle even its supposed to. I noticed in my user table in my mysql it saves the vehicle in the user table but not in the ownedvehicle table.

This is my MySQL stock of the vehicle
Код:
stock OnOwnedVehicleInsert(vehid)
{
	VehicleInfo[vehid][carID] = cache_insert_id();
	return 1;
}

stock OnPlayerBuyCar(playerid, vehid, model, color1, color2, slot, Float:ParkX, Float:ParkY, Float:ParkZ, Float:ParkA, plate[], owner[])
{
	//======================================================================================
	format(query, sizeof(query), "INSERT INTO `ownedvehicles` (model, color1, color2, parkx, parky, parkz, parka, plate, owner, owned, slot) VALUES (%d, %d, %d, %f, %f, %f, %f, '%s', '%s', %d, %d)",
	model, color1, color2, ParkX, ParkY, ParkZ, ParkA, plate, owner, 1, slot);
	mysql_function_query(dbHandle, query, true, "OnOwnedVehicleInsert", "%d", vehid);
	//======================================================================================
	format(query, sizeof(query), "UPDATE `ownedvehicles` SET `alarm` = %d, `lock` = %d, `immob` = %d, `insurances` = %d, `destroys` = %d, `gps` = %d, `fuel` = %d, `registered` = %d, `broken` = %d WHERE `owner` = '%s' AND `slot` = %d",
	0, 0, 0, 2, 0, 0, 50, 1, 0, GetName(playerid), slot);
	mysql_function_query(dbHandle, query, false, "", "");
	//======================================================================================
	format(query, sizeof(query), "UPDATE `ownedvehicles` SET `weapons` = '%s' WHERE `owner` = '%s' AND `slot` = %d", "0=0|0=0|0=0|0=0|0=0|0=0|0=0|0=0|0=0|0=0", GetName(playerid),slot);
	mysql_function_query(dbHandle, query, false, "", "");
	//======================================================================================
	format(query, sizeof(query), "UPDATE `ownedvehicles` SET `comp0` = %d, `comp1` = %d, `comp2` = %d, `comp3` = %d, `comp4` = %d, `comp5` = %d, `comp6` = %d WHERE `owner` = '%s' AND `slot` = %d",
	0, 0, 0, 0, 0, 0, 0, GetName(playerid), slot);
	mysql_function_query(dbHandle, query, false, "", "");
	//=====================================================================================
	format(query, sizeof(query), "UPDATE `ownedvehicles` SET `comp7` = %d, `comp8` = %d, `comp9` = %d, `comp10` = %d, `comp11` = %d, `comp12` = %d, `comp13` = %d, `paintjob` = %d WHERE `owner` = '%s' AND `slot` = %d",
	0, 0, 0, 0, 0, 0, 0, 3, GetName(playerid), slot);
	mysql_function_query(dbHandle, query, false, "", "");
	//=====================================================================================
	format(query, sizeof(query), "UPDATE `ownedvehicles` SET `radio` = %d, `tickets` = '%s', `dupkey` = %d, `comps` = %d WHERE `owner` = '%s' AND `slot` = %d", 0, "0|0|0|0|0|0|0|0|0|0", VehicleInfo[vehid][carDupKey], 0, GetName(playerid), slot);
	mysql_function_query(dbHandle, query, false, "", "");
	//=====================================================================================
	format(query, sizeof(query), "UPDATE `ownedvehicles` SET `drugs` = '%s' WHERE `owner` = '%s' AND `slot` = %d", "0=0|0=0|0=0|0=0|0=0|0=0|0=0|0=0|0=0|0=0|0=0|0=0|0=0|0=0|0=0|0=0|0=0|0=0|0=0|0=0", GetName(playerid), slot);
	mysql_function_query(dbHandle, query, false, "", "");
	//=====================================================================================
	format(query, sizeof(query), "UPDATE `users` SET `vehicles` = %d WHERE `name` = '%s'", PlayerInfo[playerid][pVehicles], GetName(playerid));
	mysql_function_query(dbHandle, query, false, "", "");
	//======================================================================================
	if(slot == 1)
	{
		format(query, sizeof(query), "UPDATE `users` SET `veh1` = '%s' WHERE `name` = '%s'", VehicleNames[model-400], GetName(playerid));
		format(PlayerVehicle[playerid][pVeh1], 128, "%s", VehicleNames[model-400]);
		mysql_function_query(dbHandle, query, false, "", "");
	}
	else if(slot == 2)
	{
		format(query, sizeof(query), "UPDATE `users` SET `veh2` = '%s' WHERE `name` = '%s'", VehicleNames[model-400], GetName(playerid));
		format(PlayerVehicle[playerid][pVeh2], 128, "%s", VehicleNames[model-400]);
		mysql_function_query(dbHandle, query, false, "", "");
	}
	else if(slot == 3)
	{
		format(query, sizeof(query), "UPDATE `users` SET `veh3` = '%s' WHERE `name` = '%s'", VehicleNames[model-400], GetName(playerid));
		format(PlayerVehicle[playerid][pVeh3], 128, "%s", VehicleNames[model-400]);
		mysql_function_query(dbHandle, query, false, "", "");
	}
	//======================================================================================
	return 1;
}

stock UpdateVehicleStatus(playerid, vehicle)
{
	new slot = PlayerInfo[playerid][pVehSlot];
	VehicleStatus[playerid][slot][carAlarm] = VehicleInfo[vehicle][carAlarm];
	VehicleStatus[playerid][slot][carLock] = VehicleInfo[vehicle][carLock];
	VehicleStatus[playerid][slot][carImmob] = VehicleInfo[vehicle][carImmob];
	VehicleStatus[playerid][slot][carInsurances] = VehicleInfo[vehicle][carInsurances];
	VehicleStatus[playerid][slot][carDestroyed] = VehicleInfo[vehicle][carDestroyed];
	VehicleStatus[playerid][slot][carGps] = VehicleInfo[vehicle][carGps];
	return 1;
}
Reply
#2

Replace
pawn Код:
mysql_function_query(dbHandle, query, true, "OnOwnedVehicleInsert", "%d", vehid);
with:
pawn Код:
mysql_function_query(dbHandle, query, true, "OnOwnedVehicleInsert", "d", vehid);
By the way, it's recommended to use cache even in INSERT/UPDATE queries.
Reply
#3

Thanks it works.
I also got the same error with the furniture system. I get tihs bug whenever i buy a furniture and done placed the position for it i cant edit it again or delete it. It says i dont own any furniture.
Here is the stock
Код:
stock OnPlayerBuyFurniture(houseid, interior, world, furnitureslot, model, price, name[], Float:x, Float:y, Float:z)
{
	format(query, sizeof(query), "INSERT INTO `furnitures` (model, name, houseid, interior, virworld, marketprice, posx, posy, posz) VALUES (%d, '%s', %d, %d, %d, %d, %f, %f, %f)",
	model, name, HouseInfo[houseid][hID], interior, world, price, x, y ,z);
	mysql_function_query(dbHandle, query, true, "OnFurnitureInsert", "iiiiiis[128]fff", houseid, interior, world, furnitureslot, model, price, name, x, y, z);
	return 1;
}

stock OnPlayerEditedFurniture(playerid, furnitureslot, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
{
	format(query, sizeof(query), "UPDATE `furnitures` SET `posx` = %f, `posy` = %f, `posz` = %f, `posrx` = %f, `posry` = %f, `posrz` = %f WHERE `id` = %d",
	x, y, z, rx, ry, rz, FurnitureInfo[PlayerInfo[playerid][pHouseKey]][furnitureslot][fID]);
	mysql_function_query(dbHandle, query, true, "OnFurnitureUpdatePos", "iiffffff", playerid, furnitureslot, x, y, z, rx, ry, rz);
	return 1;
}

stock OnPlayerSellFurniture(playerid, houseid, furnitureslot)
{
	format(query, sizeof(query), "DELETE FROM `furnitures` WHERE `id` = %d", FurnitureInfo[houseid][furnitureslot][fID]);
	mysql_function_query(dbHandle, query, true, "OnPlayerSoldFurniture", "idd", playerid, houseid, furnitureslot);
	return 1;
}
P.S.
What version MySQL should i use to use cache?
Reply
#4

I know this gamemode that you're using. Just wanted to let you know that it took me 3 months to make it playable and there is still a bug with timers that I couldn't find. The payday timer gets bugged and nobody receives paydays anymore.

PS : The version you have has cache already. ( That "true" from the mysql_query function is the cache )
Reply
#5

It shouldn't be like the format of sscanf - don't get confused with that. Just i d s f (according to the arguments you're passing and the order of them of course) without spaces between them.

Replace:
pawn Код:
mysql_function_query(dbHandle, query, true, "OnFurnitureInsert", "iiiiiis[128]fff", houseid, interior, world, furnitureslot, model, price, name, x, y, z);
to:
pawn Код:
mysql_function_query(dbHandle, query, true, "OnFurnitureInsert", "iiiiiisfff", houseid, interior, world, furnitureslot, model, price, name, x, y, z);
Reply
#6

So the reason of these bugs are because i am using the SSCANF format instead of the mysql ones?
Reply
#7

Sort of - not exactly "SSCANF format", I gave that example because of the s[128] you used but still an incorrect format when it just needs the correct type and only the type of the argument(s) you pass in the function.
Reply
#8

Hmmm will try learn more about it. Thanks Konstantinos.
You deserve a reputation as always
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)