⤵️Installation

Installation of mInventory Remake Resource

General Resource Installation

Step 1 - Drag And Drop

Drag and drop the " codem-inventory " folder to your resources folder.

Step 2 - SQL Insert

Insert the " insert-me " sql file to your database.

Step 3 - Start The Script

Start the script in server.cfg

Start order must be like this in the image.


Installation Adjustments for Frameworks

On the ESX Side this resource onyl supports New ESX 1.2 and further versions.

Information

If you are using qb-core 1.2.6 you don't need to do any of this steps. Just download this qb-core version and use it.

You need progress bar script to work this resource.

You can download the supported progressbar from here.

QBCore 1.2.6 Download Link

In order to use the inventory's built in market system you need to delete the " qb-market " resource from your server.

Step 1

Go to " client/functions.lua ". Find the following codes and replace them with the new ones.

Old One ⬇️

function QBCore.Functions.HasItem(items, amount)
    return exports['qb-inventory']:HasItem(items, amount)
end

New One ⬇️ ( You need to replace it with this one below. )

function QBCore.Functions.HasItem(items, amount)
    return exports['codem-inventory']:HasItem(items, amount)
end

Step 2

Go to " server/functions.lua ". Find the following codes and replace them with the new ones.

Old One ⬇️

function QBCore.Functions.UseItem(source, item)
    if GetResourceState('qb-inventory') == 'missing' then return end
    exports['qb-inventory']:UseItem(source, item)
end

New One ⬇️ ( You need to replace it with this one below. )

function QBCore.Functions.UseItem(source, item)
    if GetResourceState('codem-inventory') == 'missing' then return end
    exports['codem-inventory']:UseItem(source, item)
end

Step 3

Go to " server/functions.lua ". Find the following codes and replace them with the new ones.

Old One ⬇️

function QBCore.Functions.HasItem(source, items, amount)
    if GetResourceState('qb-inventory') == 'missing' then return end
    return exports['qb-inventory']:HasItem(source, items, amount)
end

New One ⬇️ ( You need to replace it with this one below. )

function QBCore.Functions.HasItem(source, items, amount)
    if GetResourceState('codem-inventory') == 'missing' then return end
    return exports['codem-inventory']:HasItem(source, items, amount)
end


Functions

Step 4

Go to " server/player.lua ". ( Check Data Function ) Find the following codes and replace them with the new ones.

Old One ⬇️

PlayerData.items = GetResourceState('qb-inventory') ~= 'missing' and exports['qb-inventory']:LoadInventory(PlayerData.source, PlayerData.citizenid) or {}

New One ⬇️ ( You need to replace it with this one below. )

    PlayerData.items = GetResourceState('codem-inventory') ~= 'missing' and
        exports['codem-inventory']:LoadInventory(PlayerData.source, PlayerData.citizenid) or {}

Step 5

Go to " server/player.lua ". ( Get Card Slot Function ) Find the following codes and replace them with the new ones.

Old One ⬇️

  function self.Functions.GetCardSlot(cardNumber, cardType)
        local item = tostring(cardType):lower()
        local slots = exports['qb-inventory']:GetSlotsByItem(self.PlayerData.items, item)
        for _, slot in pairs(slots) do
            if slot then
                if self.PlayerData.items[slot].info.cardNumber == cardNumber then
                    return slot
                end
            end
        end
        return nil
    end

New One ⬇️ ( You need to replace it with this one below. )

  function self.Functions.GetCardSlot(cardNumber, cardType)
        local item = tostring(cardType):lower()
        local slots = exports['codem-inventory']:GetSlotsByItem(self.PlayerData.items, item)
        for _, slot in pairs(slots) do
            if slot then
                if self.PlayerData.items[slot].info.cardNumber == cardNumber then
                    return slot
                end
            end
        end
        return nil
    end

Step 6

Go to " server/player.lua ". ( SaveFunction ) Find the following codes and replace them with the new ones.

Old One ⬇️

function QBCore.Player.Save(source)
    local ped = GetPlayerPed(source)
    local pcoords = GetEntityCoords(ped)
    local PlayerData = QBCore.Players[source].PlayerData
    if PlayerData then
        MySQL.insert(
            'INSERT INTO players (citizenid, cid, license, name, money, charinfo, job, gang, position, metadata) VALUES (:citizenid, :cid, :license, :name, :money, :charinfo, :job, :gang, :position, :metadata) ON DUPLICATE KEY UPDATE cid = :cid, name = :name, money = :money, charinfo = :charinfo, job = :job, gang = :gang, position = :position, metadata = :metadata',
            {
                citizenid = PlayerData.citizenid,
                cid = tonumber(PlayerData.cid),
                license = PlayerData.license,
                name = PlayerData.name,
                money = json.encode(PlayerData.money),
                charinfo = json.encode(PlayerData.charinfo),
                job = json.encode(PlayerData.job),
                gang = json.encode(PlayerData.gang),
                position = json.encode(pcoords),
                metadata = json.encode(PlayerData.metadata)
            })
        if GetResourceState('qb-inventory') ~= 'missing' then exports['qb-inventory']:SaveInventory(source) end
        QBCore.ShowSuccess(resourceName, PlayerData.name .. ' PLAYER SAVED!')
    else
        QBCore.ShowError(resourceName, 'ERROR QBCORE.PLAYER.SAVE - PLAYERDATA IS EMPTY!')
    end
end

New One ⬇️ ( You need to replace it with this one below. )

function QBCore.Player.Save(source)
    local ped = GetPlayerPed(source)
    local pcoords = GetEntityCoords(ped)
    local PlayerData = QBCore.Players[source].PlayerData
    if PlayerData then
        MySQL.insert(
            'INSERT INTO players (citizenid, cid, license, name, money, charinfo, job, gang, position, metadata) VALUES (:citizenid, :cid, :license, :name, :money, :charinfo, :job, :gang, :position, :metadata) ON DUPLICATE KEY UPDATE cid = :cid, name = :name, money = :money, charinfo = :charinfo, job = :job, gang = :gang, position = :position, metadata = :metadata',
            {
                citizenid = PlayerData.citizenid,
                cid = tonumber(PlayerData.cid),
                license = PlayerData.license,
                name = PlayerData.name,
                money = json.encode(PlayerData.money),
                charinfo = json.encode(PlayerData.charinfo),
                job = json.encode(PlayerData.job),
                gang = json.encode(PlayerData.gang),
                position = json.encode(pcoords),
                metadata = json.encode(PlayerData.metadata)
            })
            if GetResourceState('codem-inventory') ~= 'missing' then exports['codem-inventory']:SaveInventory(source) end
        QBCore.ShowSuccess(resourceName, PlayerData.name .. ' PLAYER SAVED!')
    else
        QBCore.ShowError(resourceName, 'ERROR QBCORE.PLAYER.SAVE - PLAYERDATA IS EMPTY!')
    end
end

Step 7

Go to " server/player.lua ". ( Save Offline Function ) Find the following codes and replace them with the new ones.

Old One ⬇️

function QBCore.Player.SaveOffline(PlayerData)
    if PlayerData then
        MySQL.Async.insert(
            'INSERT INTO players (citizenid, cid, license, name, money, charinfo, job, gang, position, metadata) VALUES (:citizenid, :cid, :license, :name, :money, :charinfo, :job, :gang, :position, :metadata) ON DUPLICATE KEY UPDATE cid = :cid, name = :name, money = :money, charinfo = :charinfo, job = :job, gang = :gang, position = :position, metadata = :metadata',
            {
                citizenid = PlayerData.citizenid,
                cid = tonumber(PlayerData.cid),
                license = PlayerData.license,
                name = PlayerData.name,
                money = json.encode(PlayerData.money),
                charinfo = json.encode(PlayerData.charinfo),
                job = json.encode(PlayerData.job),
                gang = json.encode(PlayerData.gang),
                position = json.encode(PlayerData.position),
                metadata = json.encode(PlayerData.metadata)
            })
        if GetResourceState('qb-inventory') ~= 'missing' then exports['qb-inventory']:SaveInventory(PlayerData, true) end
        QBCore.ShowSuccess(resourceName, PlayerData.name .. ' OFFLINE PLAYER SAVED!')
    else
        QBCore.ShowError(resourceName, 'ERROR QBCORE.PLAYER.SAVEOFFLINE - PLAYERDATA IS EMPTY!')
    end
end

New One ⬇️ ( You need to replace it with this one below. )

function QBCore.Player.SaveOffline(PlayerData)
    if PlayerData then
        MySQL.Async.insert(
            'INSERT INTO players (citizenid, cid, license, name, money, charinfo, job, gang, position, metadata) VALUES (:citizenid, :cid, :license, :name, :money, :charinfo, :job, :gang, :position, :metadata) ON DUPLICATE KEY UPDATE cid = :cid, name = :name, money = :money, charinfo = :charinfo, job = :job, gang = :gang, position = :position, metadata = :metadata',
            {
                citizenid = PlayerData.citizenid,
                cid = tonumber(PlayerData.cid),
                license = PlayerData.license,
                name = PlayerData.name,
                money = json.encode(PlayerData.money),
                charinfo = json.encode(PlayerData.charinfo),
                job = json.encode(PlayerData.job),
                gang = json.encode(PlayerData.gang),
                position = json.encode(PlayerData.position),
                metadata = json.encode(PlayerData.metadata)
            })
        if GetResourceState('codem-inventory') ~= 'missing' then exports['codem-inventory']:SaveInventory(PlayerData, true) end
        QBCore.ShowSuccess(resourceName, PlayerData.name .. ' OFFLINE PLAYER SAVED!')
    else
        QBCore.ShowError(resourceName, 'ERROR QBCORE.PLAYER.SAVEOFFLINE - PLAYERDATA IS EMPTY!')
    end
end

Step 8

Go to " server/player.lua ". Find the following codes and replace them with the new ones.

Old One ⬇️

function QBCore.Player.SaveInventory(source)
    if GetResourceState('qb-inventory') == 'missing' then return end
    exports['qb-inventory']:SaveInventory(source, false)
end

function QBCore.Player.SaveOfflineInventory(PlayerData)
    if GetResourceState('qb-inventory') == 'missing' then return end
    exports['qb-inventory']:SaveInventory(PlayerData, true)
end

function QBCore.Player.GetTotalWeight(items)
    if GetResourceState('qb-inventory') == 'missing' then return end
    return exports['qb-inventory']:GetTotalWeight(items)
end

function QBCore.Player.GetSlotsByItem(items, itemName)
    if GetResourceState('qb-inventory') == 'missing' then return end
    return exports['qb-inventory']:GetSlotsByItem(items, itemName)
end

function QBCore.Player.GetFirstSlotByItem(items, itemName)
    if GetResourceState('qb-inventory') == 'missing' then return end
    return exports['qb-inventory']:GetFirstSlotByItem(items, itemName)
end

New One ⬇️ ( You need to replace it with this one below. )

function QBCore.Player.SaveInventory(source)
    if GetResourceState('codem-inventory') == 'missing' then return end
    exports['codem-inventory']:SaveInventory(source, false)
end

function QBCore.Player.SaveOfflineInventory(PlayerData)
    if GetResourceState('codem-inventory') == 'missing' then return end
    exports['codem-inventory']:SaveInventory(PlayerData, true)
end

function QBCore.Player.GetTotalWeight(items)
    if GetResourceState('codem-inventory') == 'missing' then return end
    return exports['codem-inventory']:GetTotalWeight(items)
end

function QBCore.Player.GetSlotsByItem(items, itemName)
    if GetResourceState('codem-inventory') == 'missing' then return end
    return exports['codem-inventory']:GetSlotsByItem(items, itemName)
end

function QBCore.Player.GetFirstSlotByItem(items, itemName)
    if GetResourceState('codem-inventory') == 'missing' then return end
    return exports['codem-inventory']:GetFirstSlotByItem(items, itemName)
end


Step 9

Delete " qb-weapons " folder from your server


Step 10

Delete also " weapdraw.lua " file from " qb-smallresources " folder.

Last updated