CodeMInventory

CodeM Inventory

⚠️

The steps below are required only if your using lation_weed, lation_meth or lation_coke.

Add functions

In codem-inventory/editable/serverexport.lua scroll to the very bottom of the file, create a new empty line and copy the code block below and paste it in the file.

codem-inventory/editable/serverexport.lua
function AddStashItem(stashId, item, count, slot, metadata)
    if not stashId or not item then return end
    if not count then count = 1 end
    local stash = ServerStash[stashId]
    if not stash then return end
    local itemData = Config.Itemlist[item]
    if not itemData then return end
    if not slot then
        slot = FindFirstEmptySlot(stash.inventory, Config.MaxSlots)
        if not slot then return end
    end
    local added = false
    for k, v in pairs(stash.inventory) do
        k = tostring(k)
        if not v.unique or not itemData.unique then
            if v.name == itemData.name and k ~= slot then
                v.amount = v.amount + count
                added = true
                break
            end
        end
    end
    if not added then
        stash.inventory[slot] = {
            name = itemData.name,
            label = itemData.label or itemData.name,
            weight = itemData.weight or 0,
            type = itemData.type or 'item',
            amount = count,
            usable = itemData.usable or false,
            shouldClose = itemData.shouldClose or false,
            description = itemData.description or '',
            image = itemData.image or '',
            unique = itemData.unique or false,
            slot = slot,
            ammotype = itemData.ammotype or nil
        }
    end
    if metadata then
        if next(metadata) ~= nil then
            if not stash.inventory[slot].info then
                stash.inventory[slot].info = {}
            end
            stash.inventory[slot].info = {}
            stash.inventory[slot].info = metadata
        end
    end
    UpdateStashDatabase(stashId, stash.inventory)
end
 
exports('AddStashItem', AddStashItem)

Save the file & continue below.

Add items

In codem-inventory/config/metadata.js go to the very top of the file and paste in the following code:

codem-inventory/config/metadata.js
let ls = {
    weed: [
        "ls_plain_jane_bud", "ls_plain_jane_joint", "ls_plain_jane_bag",
        "ls_banana_kush_bud", "ls_banana_kush_joint", "ls_banana_kush_bag",
        "ls_blue_dream_bud", "ls_blue_dream_joint", "ls_blue_dream_bag",
        "ls_purple_haze_bud", "ls_purple_haze_joint", "ls_purple_haze_bag",
        "ls_orange_crush_bud", "ls_orange_crush_joint", "ls_orange_crush_bag",
        "ls_cosmic_kush_bud", "ls_cosmic_kush_joint", "ls_cosmic_kush_bag",
    ],
    meth: [
        "ls_liquid_meth", "ls_meth_tray", "ls_meth_box", "ls_meth",
    ],
    coke: [
        "ls_coca_base_unf", "ls_coca_base", "ls_cocaine_brick", "ls_crack_brick",
        "ls_cocaine_bag", "ls_crack_bag",
    ],
    tools: [
        "ls_watering_can", "ls_fertilizer", "ls_ammonia",
        "ls_iodine", "ls_acetone", "ls_gasoline", "ls_cement",
    ]
};

If you rename any items you must update the list above!

Add metadata

In codem-inventory/config/metadata.js search for lawyerpass, you should see:

codem-inventory/config/metadata.js
} else if (item.name.match("lawyerpass")) {
    let infoData = [
        { label: "ID", value: iteminfo.id || "Unknown" },
        { label: "Firstname", value: iteminfo.firstname || "Unknown" },
        { label: "Lastname", value: iteminfo.lastname || "Unknown" },
        { label: "Citizen", value: iteminfo.citizenid || "Unknown" }
    ];
    returnString = infoData;

Place your cursor on the highlighted line above, hit enter to create a new line and paste the following code block below:

codem-inventory/config/metadata.js
} else if (ls.weed.includes(item.name) || ls.coke.includes(item.name)) {
    let infoData = [
        { label: "Purity", value: iteminfo.purity ? iteminfo.purity + "%" : "Unknown" }
    ];
    returnString = infoData;
} else if (ls.meth.includes(item.name)) {
    let infoData = [
        { label: "Strain", value: iteminfo.strain || "Unknown" },
        { label: "Purity", value: iteminfo.purity || "Unknown" }
    ];
    returnString = infoData;
} else if (ls.tools.includes(item.name)) {
    let infoData = [
        { label: "Remaining", value: iteminfo.quality || "Empty" }
    ];
    returnString = infoData;

Restart server

Done!