MySQL/SQLite warning
#10

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.

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;
}
This should work and by the way, what I meant was:
pawn Код:
stock LoadPlayerCar(DBResult:carid)
but you don't need the stock at all.
Reply


Messages In This Thread
MySQL/SQLite warning - by Danijel. - 02.03.2014, 17:49
Re: MySQL/SQLite warning - by Konstantinos - 02.03.2014, 17:54
Re: MySQL/SQLite warning - by Danijel. - 02.03.2014, 18:02
Re: MySQL/SQLite warning - by Konstantinos - 02.03.2014, 18:04
Re: MySQL/SQLite warning - by Danijel. - 02.03.2014, 18:09
Re: MySQL/SQLite warning - by Konstantinos - 02.03.2014, 18:15
Re: MySQL/SQLite warning - by Danijel. - 02.03.2014, 18:20
Re: MySQL/SQLite warning - by Konstantinos - 02.03.2014, 18:27
Re: MySQL/SQLite warning - by Danijel. - 02.03.2014, 18:33
Re: MySQL/SQLite warning - by Konstantinos - 02.03.2014, 18:41

Forum Jump:


Users browsing this thread: 3 Guest(s)