Jump to content

a error about converting mysql module to dbconnect


Recommended Posts

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.random1, #tempTable )
            return tempTable[ran]
        else
            return false
        end
    end
end
Link to comment
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

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