Jump to content

SQL Table


mjau

Recommended Posts

Posted

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 ?

Posted

How do i ensure noone of cars gets same id ? and still how can the scipt find the vehicle with that id when the player selects one in the gridlist ?

Posted

In SQL you can search for more than one argument.

Example:

executeSQLQuery("SELECT * FROM vehicles WHERE owner = 'Castillo' AND id = '1'") 

Posted (edited)
-- 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
Posted (edited)

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

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

Eh will that get the vehicles from owner or will it not since u used if not ... ?

Posted

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 ?

Posted
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 

Posted

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 ?

Posted

It's check if owner ( or if not valid owner ) not have any vehicles.

If not valid owner then its condition passed.

Posted

so the check for owner is really not needed ?

I could just do this ?

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

Posted (edited)

You use ( dynamic data or static ) for get id?

Dynamic is tables/element data/...

Static is mysql/sql db,xml,..

Edited by Guest
Posted

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

Posted

ok tnx

local tIdRequest = executeSQLQuery ( " SELECT * FROM vehicles WHERE id = '" .. idCode .. "'" )

this was what i was looking for tnx

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