MySQL ID
#1

Hello guys, I have a question about MySQL inserting. I'm creating a house system. In my create house command I need to set the house's ID, but the problem is that I don't know how to check the next id of the house like in the table are:
1
2
3
5
IDS (without 4 because it's deleted) insert the house as ID 4.
I tried to count the lines (cache_num_rows()), but if I count them now it will make the new house with ID 5 in this case and there will be 2 houses with ID 5

I hope you understand me, sorry for my bad English!
Reply
#2

If you just run the insert query like normal you can use the LAST_INSERT_ID mysql function to get the ID of it, don't think there's any reason for it to not work on the samp mysql plugin.
Reply
#3

You may do something based on this way in the buy house command.

Let's loop tho all houses for example.

Code:
for (hID = 1; hID < MAX_HOUSES; hID++)
After you are done with this, you have to check does the house/ r the house pickup exist. Let's say..

Code:
if (!IsValidDynamicPickup(.......[hID][HousePickup])) break; //Free House ID was found.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)