server/convert.lua

-- with this command you can integrate your qb inventories into the new system
-- if you write a code for different inventories please share it with us
-- Commands only available from cmd/live consol
RegisterCommand("convertqb", function(source)
    if source > 0 then return print("Pls use on server cmd") end

    local response = MySQL.query.await('SELECT * FROM `stashitems`')
    if response and next(response) then
        for i=1, #response do
            MySQL.insert.await('INSERT INTO `tgiann_inventory_stashitems` (stash, items) VALUES (?, ?)', {
                response[i].stash, response[i].items
            })
        end
        print("stashitems converted")
    end

    local response = MySQL.query.await('SELECT * FROM `trunkitems`')
    if response and next(response) then
        for i=1, #response do
            MySQL.insert.await('INSERT INTO `tgiann_inventory_trunkitems` (plate, items) VALUES (?, ?)', {
                response[i].plate, response[i].items
            })
        end
        print("trunkitems converted")
    end

    local response = MySQL.query.await('SELECT * FROM `gloveboxitems`')
    if response and next(response) then
        for i=1, #response do
            MySQL.insert.await('INSERT INTO `tgiann_inventory_gloveboxitems` (plate, items) VALUES (?, ?)', {
                response[i].plate, response[i].items
            })
        end
        print("gloveboxitems converted")
    end

    local response = MySQL.query.await('SELECT citizenid, inventory FROM `players`')
    if response and next(response) then
        for i=1, #response do
            if response[i].inventory then
                MySQL.insert.await('INSERT INTO `tgiann_inventory_player` (citizenid, inventory, clotheinventory) VALUES (?, ?, ?)', {
                    response[i].citizenid, response[i].inventory, "[]"
                })
            end
        end
        print("Player inventorys converted")
    end

    print("Finished")
end)

Last updated