Help with vehicle IDs [SQLite]
#1

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);
            }
        }
    }
Reply


Messages In This Thread
Help with vehicle IDs [SQLite] - by LocMax - 28.06.2014, 19:14

Forum Jump:


Users browsing this thread: 1 Guest(s)