SA-MP Forums Archive
Help with vehicle IDs [SQLite] - 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: Help with vehicle IDs [SQLite] (/showthread.php?tid=522681)



Help with vehicle IDs [SQLite] - LocMax - 28.06.2014

So, I have a problem where I save vehicles with SQLite, and then if I delete one vehicle, there'll be an empty ID.

For example:
I have vehicles:
ID 1, 2,3,4,5
I delete vehicle ID 3
Then I get 1,2,4,5

So how can I make it that after server restart the vehicle IDs are equal to the row number?

Currently I have this, but it doesn't work.
pawn Код:
new DBResult:re = db_query(BFU, "SELECT * FROM vehicles");
    for(new i = 0; i < db_num_rows(re); i++)
    {
        for(new x=1; x < MAX_VEHICLES; x++)
        {
            if(i != x)
            {
                new q[128];
                format(q,sizeof(q), "UPDATE vehicles SET id = %d", i);
                db_query(BFU, q);
                db_next_row(re);
            }
        }
    }