SA-MP Forums Archive
Load Vehicles + MYSQL - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Load Vehicles + MYSQL (/showthread.php?tid=441812)



Load Vehicles + MYSQL - Stefand - 04.06.2013

Well, My vehicle system works all fine but my CarFileID is Auto_Increasement.
When I delete a vehicle it just keeps counting up, for example, I have vehicle 1 2 3 4 5 6, and I delete 4 it will continue with 7 8 9 10...

Is there a way to change that?

if not, how can I change this code:
to make it work that it just loads Every single vehicle data, not including CarFileID?
pawn Код:
stock InitVehicles()
{
    new query[400];
    for(new id; id < MAX_VEHICLES; id++) // Goes through all the slots, looking for the data
    {
        format(query, sizeof(query), "SELECT * FROM `Vehicles` WHERE `CarFileID` = '%d'", id); // Selects all the information from the table
        mysql_function_query(g_connectionHandle, query, true, "LoadVehiclesCallback", "d", id);
    }
    return 1;
}



Re: Load Vehicles + MYSQL - Vince - 04.06.2013

I'd say use a while loop, but I just noticed there is caching. Either way;

pawn Код:
mysql_function_query(g_connectionHandle, "SELECT * FROM Vehicles", true, "LoadVehiclesCallback", "d", id);
pawn Код:
new
    rows,
    fields;

cache_get_data(rows, fields, g_connectionHandle);

for(new i; i < rows; i++)
{
    new carFileId = cache_get_row_int(i, 0, g_connectionHandle);
    // Load stuff
}



Re: Load Vehicles + MYSQL - Stefand - 04.06.2013

Quote:
Originally Posted by Vince
Посмотреть сообщение
I'd say use a while loop, but I just noticed there is caching. Either way;

pawn Код:
mysql_function_query(g_connectionHandle, "SELECT * FROM Vehicles", true, "LoadVehiclesCallback", "d", id);
pawn Код:
new
    rows,
    fields;

cache_get_data(rows, fields, g_connectionHandle);

for(new i; i < rows; i++)
{
    new carFileId = cache_get_row_int(i, 0, g_connectionHandle);
    // Load stuff
}
This still does not stop this right?
Well, My vehicle system works all fine but my CarFileID is Auto_Increasement.
When I delete a vehicle it just keeps counting up, for example, I have vehicle 1 2 3 4 5 6, and I delete 4 it will continue with 7 8 9 10...