Mann56 Posted January 30, 2016 Share Posted January 30, 2016 Hey guys, I've been working on a vehicle-system and i want to retrieve an item from a table, which i don't know how to do... function(thePlayer) local owner = getAccountName(getPlayerAccount(thePlayer)) local check = dbPoll(dbQuery(connection,"SELECT Id FROM purchasedCars WHERE Owner = ? AND Slot = ?",owner,1),-1) if #check == 1 then -- I want to get the model id present inside table in a variable 'id' here local x,y,z = getElementPosition(thePlayer) createVehicle(id,x+5,y+5,z) end end Some help would be appreciated. I just want the model id from the table 'check' , table.concat didn't work... Link to comment
Mann56 Posted January 30, 2016 Author Share Posted January 30, 2016 Well i did : function(thePlayer) local owner = getAccountName(getPlayerAccount(thePlayer)) local check = dbPoll(dbQuery(connection,"SELECT Id FROM purchasedCars WHERE Owner = ? AND Slot = ?",owner,1),-1) if #check == 1 then local id = table.concat(check) outputChatBox(id) local x,y,z = getElementPosition(thePlayer) createVehicle(id,x+5,y+5,z) end end it Said: Invalid value (table) at index 1 in table for 'concat' Link to comment
KariiiM Posted January 30, 2016 Share Posted January 30, 2016 Try that, function(thePlayer) local owner = getAccountName(getPlayerAccount(thePlayer)) local check = dbPoll(dbQuery(connection,"SELECT Id FROM purchasedCars WHERE Owner = ? AND Slot = ?",tostring(owner),1),-1) if type(check) == "table" and #check > 0 then local id = tostring(check[1]["Id"]) local x,y,z = getElementPosition(thePlayer) createVehicle(id,x+5,y+5,z) end end Link to comment
Mann56 Posted January 30, 2016 Author Share Posted January 30, 2016 Thanks Karim, it worked!! So you got the first index under column Id... Thanks i'll keep this method in mind. Link to comment
KariiiM Posted January 30, 2016 Share Posted January 30, 2016 Thanks Karim, it worked!! So you got the first index under column Id... Thanks i'll keep this method in mind. You're welcome Link to comment
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