mjau Posted March 22, 2012 Posted March 22, 2012 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 ?
Castillo Posted March 22, 2012 Posted March 22, 2012 You can assign a unique ID to each vehicle you buy. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
mjau Posted March 22, 2012 Author Posted March 22, 2012 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 ?
Castillo Posted March 22, 2012 Posted March 22, 2012 In SQL you can search for more than one argument. Example: executeSQLQuery("SELECT * FROM vehicles WHERE owner = 'Castillo' AND id = '1'") San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
mjau Posted March 22, 2012 Author Posted March 22, 2012 ok i see but how to ensure a 2 cars dont get same id
drk Posted March 22, 2012 Posted March 22, 2012 (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 March 22, 2012 by Guest EPT Team Server Development: 0% Learning C++ | C++ is amazing
Kenix Posted March 22, 2012 Posted March 22, 2012 (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 March 22, 2012 by Guest http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
drk Posted March 22, 2012 Posted March 22, 2012 Ah, my bad EPT Team Server Development: 0% Learning C++ | C++ is amazing
mjau Posted March 22, 2012 Author Posted March 22, 2012 kenix that will check if not owner = to kenix too wont it ?
Kenix Posted March 22, 2012 Posted March 22, 2012 Not understand you. http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
drk Posted March 22, 2012 Posted March 22, 2012 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. EPT Team Server Development: 0% Learning C++ | C++ is amazing
mjau Posted March 22, 2012 Author Posted March 22, 2012 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 ... ?
Kenix Posted March 22, 2012 Posted March 22, 2012 You need check if owner have vehicles? http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
mjau Posted March 22, 2012 Author Posted March 22, 2012 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 ?
Kenix Posted March 22, 2012 Posted March 22, 2012 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 http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
mjau Posted March 22, 2012 Author Posted March 22, 2012 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 ?
Kenix Posted March 22, 2012 Posted March 22, 2012 It's check if owner ( or if not valid owner ) not have any vehicles. If not valid owner then its condition passed. http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
mjau Posted March 22, 2012 Author Posted March 22, 2012 so the check for owner is really not needed ? I could just do this ? if not executeSQLQuery ( " SELECT * FROM vehicles WHERE id = '" .. idCode .. "'" ) then
Kenix Posted March 22, 2012 Posted March 22, 2012 (edited) You use ( dynamic data or static ) for get id? Dynamic is tables/element data/... Static is mysql/sql db,xml,.. Edited March 22, 2012 by Guest http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
mjau Posted March 22, 2012 Author Posted March 22, 2012 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...
mjau Posted March 22, 2012 Author Posted March 22, 2012 ok tnx local tIdRequest = executeSQLQuery ( " SELECT * FROM vehicles WHERE id = '" .. idCode .. "'" ) this was what i was looking for tnx
Kenix Posted March 22, 2012 Posted March 22, 2012 No problem. http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now