Jump to content

SQL Table


mjau

Recommended Posts

Hi if i make a sql table wich i fill with vehicles players buy and when they go to storage to execute a action on them i need to find the right vehicle of all the vehicles that player owns

to ensure i only get the clients vehicles i check his acc name with the acc name in db

anyway if a player got 23 infernuses how the heck do i ensure the action he is trying to do on the gridlist gets done on the right car in the table ?

Link to comment
-- Your code 
    if ( not executeSQLQuery [[ SELECT * FROM vehicles WHERE owner = 'Draken' AND id = '" .. idCode .. "' ]] ) then 
        -- Buy the vehicle and assign the ID 
    else 
        -- Put your code here to generate new id then check again if id exists already 
end 

Good idea is create a function to generate a id then use the while loop to check if generated id exists.

Edited by Guest
Link to comment

It's correct

-- Your code 
if not executeSQLQuery ( " SELECT * FROM vehicles WHERE owner = 'Kenix' AND id = '" .. idCode .. "'" ) then 
    -- Buy the vehicle and assign the ID 
else 
    -- Put your code here to generate new id then check again if id exists already 
end 

Draken, You can use

[[ ]] 

only if you have string ONLY. Not If you have concats or something.

Ex

print [[ Hello \n all! ]] --> Hello \n all! 
  

Edited by Guest
Link to comment
It's correct
-- Your code 
if not executeSQLQuery ( " SELECT * FROM vehicles WHERE owner = 'Kenix' AND id = '" .. idCode .. "'" ) then 
    -- Buy the vehicle and assign the ID 
else 
    -- Put your code here to generate new id then check again if id exists already 
end 

Draken, You can use

[[ ]] 

only if you have string ONLY. Not If you have concats or something.

Ex

print [[ Hello \n all! ]] --> Hello \n all! 
  

I think not. When I made a simple statistics system I used [[ ]] on it and worked.

Link to comment

look i got a table with all vehicles wich has been bought in server and when i get them i do

executeSQLQuery ( " SELECT * FROM vehicles WHERE owner = 'Kenix'

but if u put if not infront of it it will check all the vehicles in the table wont it ?

Link to comment
local tRequest = executeSQLQuery ( " SELECT * FROM vehicles WHERE owner = 'Kenix' AND id = '" .. idCode .. "'" ) 
if not tRequest or #tRequest == 0 then -- If owner with id not have any vehicles. 
    -- TODO 
else -- If Have. 
    -- TODO 
end 

Link to comment

you dont understand me i mean when you do this

if not executeSQLQuery ( " SELECT * FROM vehicles WHERE owner = 'Kenix' AND id = '" .. idCode .. "'" ) then 

doesnt that mean that if not owner = kenix ?

like dont u check if kenix is not the owner there ?

Link to comment

well idk how to find the id yet but i dont understand why u want the owner to have no vehicles before u check if the id is in the table ?

To find the id i will just do math.random or a loop wich counts until it ifnds a number not in table...

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...