RX Scripts Logo
BlackMarkets

Configurables

All config & open sourced files included within this script.

Config Files

--[[
BY RX Scripts © rxscripts.xyz
--]]

Config = {}

Config.Locale = 'en'
Config.Money = 'black_money' -- The type of money that will be used to pay for the items.
Config.ImgDirectory = 'ox_inventory/web/images/' -- The directory where the images are stored.

Config.PickUp = { -- Picking up the item after its bought
    enabled = true, -- If this is set to false, the pickup will be ignored and the item will be added to the players inventory.
    locations = {
        vector4(372.2360, 3409.7803, 35.4053, 66.8821),
        vector4(370.9602, 3412.5112, 35.4057, 111.8046),
    },
    model = 'g_m_m_chicold_01', -- The model of the ped that will be spawned.
}

Config.RandomLocations = { -- Random locations for the black market laptop.
    vector4(92.8279, 3751.4629, 40.7711, 326.4801),
}

Config.TrackClosestMarket = { -- Tracks the most nearby black market the player has access to.
    enabled = true,
    item = 'tracker', -- Do not use the same item as other markets have as tracker.
    remove = true,
    time = 60,
}

Config.BlackMarkets = {
    ['Criminal Market'] = { -- The name of the black market must be unique.
        coords = vector4(92.7370, 3754.4297, 40.5986, 70.0),
        type = 'laptop', -- 'laptop' or 'ped'
        pedModel = 'a_m_y_hasjew_01', -- The model of the ped that will be spawned, only used if type is 'ped'.
        randomizeLocation = false, -- Overrides the coords above and randomizes the location from the Config.RandomLocations table.
        purchaseCooldown = 120, -- The cooldown in seconds before the player can purchase again.
        trackLocation = {
            enabled = true,
            item = 'phone', -- Unique item that will be used to track the location of the black market.
            remove = true, -- If this is set to true, the item will be removed from the players inventory.
            time = 60, -- The amount of time in seconds that the blip/route will be shown on the map.
        },
        requiredItem = {
            enabled = true,
            item = 'phone',
            remove = false, -- If this is set to true, the item will be removed on opening the black market.
        },
        jobsRequired = {
            enabled = false,
            jobs = {
                "dealer",
            }
        },
        randomizeItems = {
            enabled = false,
            amount = 3,
        },
        payWithItem = {
            enabled = false, -- If this is set to false, the item will be paid with an money account, otherwise the price will be the amount of the item required.
            item = 'coin',
            itemLabel = 'Coin',
        },
        items = {
            {
                item = "WEAPON_ASSAULTRIFLE",
                label = 'Assault Rifle',
                price = 3,
            },
            {
                item = "ammo-rifle2",
                label = 'Rifle Ammo 2',
                price = 100,
            },
            {
                item = "bodybag",
                label = 'Body Bag',
                price = 2500,
            },
            {
                item = "armour",
                label = 'Armour',
                price = 3500,
            },
            {
                item = "at_flashlight",
                label = 'Flashlight',
                price = 100,
            },
        }
    },
}

--[[
    INITIALIZATION SECTION

    ONLY UNCOMMENT/CHANGE THIS IF YOU HAVE RENAMED SCRIPTS SUCH AS FRAMEWORK, TARGET, INVENTORY ETC
    RENAME THE SCRIPT NAME TO THE NEW NAME
--]]
-- ESX = 'es_extended'
-- QB = 'qb-core'
-- OXTarget = 'ox_target'
-- QBTarget = 'qb-target'
IgnoreResourceNotFoundErrors = false

Opensource Files

All script-related open source code is contained within these files. Third-party components, including frameworks, inventory systems, and other external code, are separately maintained & open sourced in our fmLib repository.
--[[
BY RX Scripts © rxscripts.xyz
--]]

function Notify(msg, type)
    if Core == 'ESX' then
        CoreObj.ShowNotification(msg, type)
    elseif Core == 'QB' then
        CoreObj.Functions.Notify(msg, type)
    end
end

function AddTarget(name, bOptions)
    if Target == 'OX' then
        exports.ox_target:addLocalEntity(bOptions.obj, {
            {
                label = "Open " .. name,
                name = name,
                icon = "fas fa-laptop",
                iconColor = "black",
                distance = 2.5,
                onSelect = function()
                    OpenBlackMarket(name, bOptions)
                end,
            },
        })
    elseif Target == 'QB' then
        exports['qb-target']:AddTargetEntity(bOptions.obj, {
            options = {
                {
                    num = 1,
                    icon = "fas fa-laptop",
                    label = "Open " .. name,
                    action = function()
                        OpenBlackMarket(name, bOptions)
                    end
                },
            },
            distance = 2.5
        })
    end
end

function AddPickupTarget(entity, name, location)
    if Target == 'OX' then
        exports.ox_target:addLocalEntity(entity, {
            {
                label = "Pickup Items",
                name = name,
                icon = "fas fa-boxes",
                iconColor = "red",
                distance = 2.5,
                onSelect = function()
                    PickupItems(location)
                end,
            },
        })
    elseif Target == 'QB' then
        exports['qb-target']:AddTargetEntity(entity, {
            options = {
                {
                    num = 1,
                    icon = "fas fa-boxes",
                    label = "Pickup Items",
                    action = function()
                        PickupItems(location)
                    end
                },
            },
            distance = 2.5
        })
    end
end

function HasItem(item)
    if Core == 'ESX' then
        local has = CoreObj.SearchInventory(item, 1)
        return has and has > 0
    elseif Core == 'QB' then
        return CoreObj.Functions.HasItem(item)
    end
end

function IsJobAllowed(jobs)
    if Core == 'ESX' then
        local playerData = CoreObj.GetPlayerData()

        for k, v in pairs(jobs) do
            if playerData.job.name == v then
                return true
            end
        end
    elseif Core == 'QB' then
        local playerData = CoreObj.Functions.GetPlayerData()

        for k, v in pairs(jobs) do
            if playerData.job.name == v then
                return true
            end
        end
    end

    return false
end