fatboy950412 Posted June 12, 2021 Share Posted June 12, 2021 hi im trying to convert dbconnect this text and i doing correctly but it isnt working here is the code; function getRandomVehicleFromCarshop(shopID) if shopID and tonumber(shopID) then local preparedQuery = "SELECT * FROM `vehicles_shop` WHERE `enabled` = '1' AND `spawnto`='"..exports.global:toSQL(shopID).."' " local q1 = mysql:query(preparedQuery) if not q1 then outputDebugString("Database error / getRandomVehicleFromCarshop / carshop-sytem / s_shop.lua") return false end local tempTable = {} while true do local row = mysql:fetch_assoc(q1) if not row then break end table.insert(tempTable, row ) end mysql:free_result(q1) if #tempTable > 0 then local ran = math.random( 1, #tempTable ) return tempTable[ran] else return false end end end Link to comment
saluta Posted June 12, 2021 Share Posted June 12, 2021 Spoiler db = dbConnect("sqlite", "database.db") dbExec(db, "CREATE TABLE IF NOT EXISTS VehicleList (Account, X, Y, Z)") server.lua try so in backend paste this code. Link to comment
fatboy950412 Posted June 12, 2021 Author Share Posted June 12, 2021 17 minutes ago, saluta said: Hide contents db = dbConnect("sqlite", "database.db") dbExec(db, "CREATE TABLE IF NOT EXISTS VehicleList (Account, X, Y, Z)") server.lua try so in backend paste this code. nah im not saying this can you convert this module to db? Link to comment
saluta Posted June 12, 2021 Share Posted June 12, 2021 3 minutes ago, fatboy950412 said: нет, я этого не говорю вы можете преобразовать этот модуль в db? Spoiler addEventHandler ("onResourceStart", resourceRoot, function () db = dbConnect ("sqlite", "database.db") dbExec (db, "CREATE TABLE IF NOT EXISTS VehicleList (ID, Account, Model, X, Y, Z, RotZ, Colors)") for i, player in ipairs (getElementsByType ("player")) do updateVehicleInfo (player) end end) In this case, the database stores the color of the account and coordinates of the car. Читайте тут: dbConnect 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