02.03.2014, 18:41
You execute a query to set the data to the database and then you execute another query to get them back? Totally pointless. Assign them directly.
This should work and by the way, what I meant was:
but you don't need the stock at all.
pawn Код:
stock CreatePlayerCar(playerid, mid, col1, col2)
{
new Query[512], DBResult: idc, carid;
format(Query, sizeof(Query), "INSERT INTO CARS (MODELID) VALUES(%d)", mid);
db_query(Database, Query);
idc = db_query(Database, "SELECT * FROM CARS");
rows = db_num_rows(idc);
db_free_result(idc);
format(Query, sizeof(Query), "UPDATE CARS SET FUEL = '40.0', X = '2159.5457', Y = '-2321.5134', Z = '15.1379', ANGLE = '0.0', COLOR1 = '%d', COLOR2 = '%d' WHERE ID = %i", col1, col2, carid);
db_query(Database, Query);
CarInfo[carid][ModelID] = mid;
CarInfo[carid][Color1] = col1;
CarInfo[carid][Color2] = col2;
CarInfo[carid][cFuel] = 40;
CarInfo[carid][cX] = 2159.5457;
CarInfo[carid][cY] = -2321.5134;
CarInfo[carid][cZ] = 15.1379;
CarInfo[carid][cRot] = 0.0;
SendClientMessage(playerid, WHITE, "Kupili ste auto.");
return true;
}
pawn Код:
stock LoadPlayerCar(DBResult:carid)