djharbi2 Posted July 30, 2019 Posted July 30, 2019 (edited) Hi, I want to print the matching value but I can't Can you help, thank you ... server.Lua local vehDB = dbConnect( 'sqlite', 'vehicle.db' ) dbExec(vehDB,' CREATE TABLE IF NOT EXISTS `vehicle_base` (pAcc, vehicleID, vehicleName, vehiclePrice, vehicleStatus, vehicleHP)') function dategetV() local results = dbPoll(dbQuery(vehDB, "SELECT * FROM `vehicle_base` WHERE vehicleID=? AND pAcc=?",520,getAccountName(getPlayerAccount(source))), -1) if results then for k,v in ipairs ( results ) do outputDebugString(tostring(v['vehicleHP'])) end end end addEvent("dategetV", true) addEventHandler("dategetV", getRootElement(getThisResource()), dategetV) Edited July 30, 2019 by djharbi2
HassoN Posted July 30, 2019 Posted July 30, 2019 @djharbi2 What do you mean by the matching value? Explain your issue better so we can assist you. * There is No God but Allah discord: HassoN#2709 Visit my wiki profile: https://wiki.multitheftauto.com/wiki/User:Hassan_saad
djharbi2 Posted July 31, 2019 Author Posted July 31, 2019 want to pull the vehicleHP value of the matching person For example: djharbi, 520, infernus, 100, good,1000 (This is a sample data) The data I want > 1000 (vehicleHP)
HassoN Posted July 31, 2019 Posted July 31, 2019 3 hours ago, djharbi2 said: want to pull the vehicleHP value of the matching person For example: djharbi, 520, infernus, 100, good,1000 (This is a sample data) The data I want > 1000 (vehicleHP) That's exactly what your code does. So what's your issue? Nothing prints out even if the value exists in the database? * There is No God but Allah discord: HassoN#2709 Visit my wiki profile: https://wiki.multitheftauto.com/wiki/User:Hassan_saad
HassoN Posted July 31, 2019 Posted July 31, 2019 1 hour ago, djharbi2 said: yes that's exactly the problem At line 5, use tostring(520) instead of 520. * There is No God but Allah discord: HassoN#2709 Visit my wiki profile: https://wiki.multitheftauto.com/wiki/User:Hassan_saad
HassoN Posted July 31, 2019 Posted July 31, 2019 2 minutes ago, djharbi2 said: problem persists Your code seems fine to me. Try to install DB browser to check if all the values really exist in your database. * There is No God but Allah discord: HassoN#2709 Visit my wiki profile: https://wiki.multitheftauto.com/wiki/User:Hassan_saad
djharbi2 Posted July 31, 2019 Author Posted July 31, 2019 If you recreate the above code, I would be glad, you can do it
HassoN Posted July 31, 2019 Posted July 31, 2019 (edited) 19 minutes ago, djharbi2 said: If you recreate the above code, I would be glad, you can do it local vehDB = dbConnect("sqlite", "vehicle.db") dbExec(vehDB, "CREATE TABLE IF NOT EXISTS vehicle_base (pAcc TEXT, vehicleID TEXT, vehicleName TEXT, vehiclePrice TEXT, vehicleStatus TEXT, vehicleHP TEXT)") function dateGetV() local accName = getAccountName(getPlayerAccount(source)) local qh = dbQuery(vehDB, "SELECT * FROM vehicle_base WHERE vehicleID=? AND pAcc=?", "520", accName) local result = dbPoll(qh, -1) if result then for _, row in ipairs(result) do outputDebugString(row["vehicleHP"]) end end end addEvent("dategetV", true) addEventHandler("dategetV", root, dateGetV) I'd do like this. Edited July 31, 2019 by HassoN 1 * There is No God but Allah discord: HassoN#2709 Visit my wiki profile: https://wiki.multitheftauto.com/wiki/User:Hassan_saad
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