Array size problem- Problems with autoincrement values
#4

I would remove the auto-increment from your ID column.

When I create a house, I try to add the data to the array itself before adding it to the database.
That one is easy because you can just loop through your array from 1 to 1999 (I'm not using HouseID 0 in my scripts) and find a free spot.

When there is room to add a house (you have less than 2000 houses), add the data to the array.
When that's done, save the data to the database, using the array-index as HouseID.

No need to use auto-increment in the database, no worries about ever getting higher HouseID values above your MAX_HOUSES variable.

And when you update/delete a house on the server, you can directly use the array-index as this IS the HouseID.

HouseID's previously created and deleted will be used again when you create a new house.
Let's say you have 500 houses and you delete HouseID 371.

This means you have a gap (empty space) in your array at index 371.
The next time you create a new house, it will use this free spot to create a new house.

Auto-increment should only be used for players in my opinion, and probably house-vehicles (data that cannot link directly to an array-index).
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)