Installation

If you aren't familiar with programming or just you don't know how to set up the script, we present our installation guide which is as comprehensive as possible so you don't have any difficulties.


STEP 1 - Dependencies

Dependencies are important extensions without which the script can't work.

STEP 2 - Resource order

You MUST start the resource below your core (es_extended/qb-core/qbx_core)!

SERVER.CFG
start es_extended/qb-core/qbx_core
start mst_drugdetector

STEP 3 - Database

DELETE FROM items WHERE name = 'drugdetector';
DELETE FROM items WHERE name = 'drugdetector_used';
DELETE FROM items WHERE name = 'joint';
DELETE FROM items WHERE name = 'cocaine';
DELETE FROM items WHERE name = 'ecstasy';
DELETE FROM items WHERE name = 'meth';
DELETE FROM items WHERE name = 'heroin';
DELETE FROM items WHERE name = 'morphine';
DELETE FROM items WHERE name = 'xanax';

INSERT INTO `items` (`name`, `label`, `weight`) VALUES
	('drugdetector', 'Drug Detector', 1),
	('drugdetector_used', 'Used Drug Detector', 1),
	('joint', 'Joint', 1),
	('cocaine', 'Cocaine', 1),
	('ecstasy', 'Ecstasy', 1),
	('meth', 'Methamphetamine', 1),
	('heroin', 'Heroin', 1),
	('morphine', 'Morphine', 1),
	('xanax', 'Xanax', 1)
;

STEP 4 - Inventory Metadata

Most of inventory systems automatically detect metadata, but others require manual configuration.

Insert this block of code in tgiann-inventory/configs/configMetadataAdvance.lua

drugdetector_used = function(metadata, currentLang)
        local L
        do
            local ok, labels = pcall(function()
                return exports['mst_drugdetector']:GetDrugDetectorLocaleLabels()
            end)
            if ok and type(labels) == 'table' then
                L = {
                    officer = labels.officer or "",
                    tested = labels.tested or "",
                    result = labels.result or "",
                    date_time = labels.date_time or "",
                }
            else
                L = { officer = "", tested = "", result = "", date_time = "" }
            end
        end

        local row = [[
        <div class="item_info_row">
            <div class="item_info_row_left">%s</div>
            <div class="item_info_row_right">%s</div>
        </div>
        ]]

        local rows = {}

        table.insert(rows, row:format(L.officer, metadata and (metadata.officer or "-") or "-"))
        table.insert(rows, row:format(L.tested, metadata and (metadata.tested or "-") or "-"))
        table.insert(rows, row:format(L.result, metadata and (metadata.testResult or "-") or "-"))
        table.insert(rows, row:format(L.date_time, metadata and (metadata.dateTime or "-") or "-"))

        local html = [[ <div class="item_info_container">%s</div> ]]
        return html:format(table.concat(rows, "\n"))
end,

STEP 5 - Not working?

We hope you won’t need this step, but if you do, feel free to join our Discord and open a support ticket. :)

Last updated