SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Thread Tools Display Modes
Old 19/01/2019, 11:06 AM   #1
Kraeror's Avatar
Join Date: Mar 2017
Location: Bulgaria
Posts: 534
Reputation: 19
Default MySQL ID

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:
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!
Kraeror is offline   Reply With Quote
Old 19/01/2019, 12:59 PM   #2
Big Clucker
Join Date: Jul 2015
Location: England
Posts: 61
Reputation: 10
Default Re: MySQL ID

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.
Chyakka is offline   Reply With Quote
Old 19/01/2019, 01:11 PM   #3
Huge Clucker
Hunud's Avatar
Join Date: Jun 2016
Location: Right here.
Posts: 484
Reputation: 57
Default Re: MySQL ID

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

Let's loop tho all houses for example.

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..

if (!IsValidDynamicPickup(.......[hID][HousePickup])) break; //Free House ID was found.
Hunud is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Plugin r39-2 Error: Can't connect to local MySQL server through socket Emre__ Scripting Help 10 30/07/2014 08:26 AM
[Tutorial] [VIDEO] MySQL ORM r38: How to pair GM with MySQL & creation of registration/connection system cArnasLT Tutorials 3 19/05/2014 02:08 PM
[GameMode] MySQL CLEAN GAMEMODE [Whirlpool, MySQL BlueG R7, Cache, Ready Package (Windows)] GiamPy. Gamemode Scripts 13 13/09/2013 04:31 PM
BlueG MySQL plugin - Failed (plugins/ undefined symbol: _Z13stringvprintfPKcPc) linuxthefish Plugin Development 10 13/07/2013 10:56 AM
[Tool/Web/Other] MySQL DB Manager - Easily manage your MySQL databases with this remote application fiki574 Tools and Files 13 22/07/2012 09:41 AM

All times are GMT. The time now is 07:29 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.