📝Configurables

Config Files

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

Config = {}

--[[ 
    YOU CAN CREATE THE DRUGLABS IN config/labs/**.lua FILES
--]]
Config.DrugLabs = {}

Config.SaveInterval = 10 -- saves data every x minutes
Config.Locale = 'en'
Config.DefaultRoutingBucket = 0 -- default routing bucket for players

Config.MaxLabsOwned = 1 -- how many labs can a player own
Config.SellPercentage = 0.75 -- percentage of the lab price to return to the player when selling
Config.UseMoney = 'black_money' -- money type to purchase lab

Config.CopsRaid = { -- raid settings for the cops, minigame/progress duration etc can be changed in client/opensource.lua)
    enabled = true,
    openDoorDuration = 3, -- in minutes (how long will the door be open for everyone, after this the lab will be disabled for the cooldown below)
    labDisabledCooldown = 60 * 24, -- in minutes (how long will the lab be disabled to use after a raid)
    copsRequired = 1, -- how many cops are required to be online to raid a lab, takes job from Config.CopsRaid.allowedJob
    allowedJob = { name = 'police', minGrade = 1 }, -- job and min grade required to start a raid
    requiredItems = { -- items required to raid
        { item = 'phone', amount = 1, remove = true }
    },
}

Config.Security = {
    price = 50000,
    protectWorkers = true, -- if true, workers will not 'arrested' by the cops and hide until lab is back running again
    protectWorkersInventory = true, -- if true, workers inventory will not be able to be taken by cops during a raid
}

Config.StashGrades = {
    { -- DEFAULT GRADE
        price = 0,
        weight = 10000,
        slots = 10,
    },
    {
        price = 25000,
        weight = 25000,
        slots = 20,
    },
    {
        price = 50000,
        weight = 50000,
        slots = 30,
    }
}

Config.Blips = {
    ownedLab = { -- blip seen by the owner of the lab
        enabled = true,
        sprite = 473,
        color = 3,
        scale = 0.8,
        display = 4,
        shortrange = true,
        label = '%s', -- %s will be replaced with the lab name
    },
    unownedLab = { -- blip seen by everyone if the lab has no owner
        enabled = true,
        sprite = 473,
        color = 0,
        scale = 0.8,
        display = 4,
        shortrange = true,
        label = '%s ($%s)', -- 1st %s will be replaced with the lab name, 2nd %s will be replaced with the lab price
    },
}

Config.EntranceNPC = {
    model = "s_m_m_highsec_01",
    anims = {
        failPurchase = {
            dict = "misscommon@response",
            anim = "screw_you"
        },
        successPurchase = {
            dict = "mp_ped_interaction",
            anim = "handshake_guy_a",
        },
    },
    scenarios = {
        forSaleStanding = "WORLD_HUMAN_CLIPBOARD",
        ownedStanding = "WORLD_HUMAN_GUARD_STAND",
    }
}

--[[
    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

    IF IT CANT FIND A TARGET IT WILL WORK WITH 3D TEXT + OX_LIB CONTEXT MENU
--]]

-- FM = 'fmLib'
-- OXTarget = 'ox_target'
-- QBTarget = 'qb-target'
IgnoreResourceNotFoundErrors = false
IgnoreResourceInitializedLogs = false

Opensource Files

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

---@return boolean | nil
function RaidMinigame(hasSecurity)
    TaskStartScenarioInPlace(playerPed, "WORLD_HUMAN_STAND_MOBILE", 0, true)
    local result
    
    -- You can use hasSecurity to check if the lab has security, to make the raid harder
    if hasSecurity then
        result = lib.skillCheck({'medium', 'medium', 'hard'}, {'w', 'a', 's', 'd'})
    else
        result = lib.skillCheck({'easy', 'easy', 'easy'}, {'w', 'a', 's', 'd'})
    end

    ClearPedTasks(playerPed)
    
    -- Must return: true, false or nil
    return result
end

function ShowMarker(type, coords)
    if type == 'laptop' or type == 'door' or type == 'stash' or type == 'action' then
        DrawMarker(2, coords, 0, 0, 0, 0, 180.0, 0, 0.3, 0.3, 0.3, 204, 0, 102, 100, false, false, 2, true, false, false, false)
    end
end

-- Only works with qb-target or ox_target started
function InitEntranceTarget(labId)
    local lab = Labs[labId]
    if not lab then return end

    if OXTarget then
        OXTarget:addLocalEntity(lab.ped, {
            {
                name = 'enter'..labId,
                label = 'Enter '..lab.name,
                icon = 'fas fa-sign-in-alt',
                distance = 2.5,
                canInteract = function()
                    return lab.owner and (lab.code or lab.lastraid)
                end,
                onSelect = function()
                    EnterLab(labId)
                end
            },
            {
                name = 'changecode'..labId,
                label = 'Set Code',
                icon = 'fas fa-key',
                distance = 2.5,
                canInteract = function()
                    return lab.owner and lab.owner == FM.player.getIdentifier()
                end,
                onSelect = function()
                    ChangeCode(labId)
                end
            },
            {
                name = 'buy'..labId,
                label = 'Buy '..lab.name..' ($'..lab.price..')',
                icon = 'fas fa-dollar-sign',
                distance = 2.5,
                canInteract = function()
                    return not lab.owner
                end,
                onSelect = function()
                    OpenBuyLabDialog(labId)
                end
            },
            {
                name = 'raid'..labId,
                label = 'Raid '..lab.name,
                icon = 'fas fa-handcuffs',
                distance = 2.5,
                canInteract = function()
                    return Config.CopsRaid.enabled and CurrentJob and CurrentJob.name == Config.CopsRaid.allowedJob.name and CurrentJob.grade >= Config.CopsRaid.allowedJob.minGrade and lab.owner
                end,
                onSelect = function()
                    RaidLab(labId)
                end
            }
        })
    elseif QBTarget then
        QBTarget:AddTargetEntity(lab.ped, {
            options = {
                {
                    label = 'Enter '..lab.name,
                    icon = 'fas fa-sign-in-alt',
                    targeticon = 'fas fa-sign-in-alt',
                    action = function()
                        EnterLab(labId)
                    end,
                    canInteract = function()
                        return lab.owner and (lab.code or lab.lastraid)
                    end,
                },
                {
                    label = 'Set Code',
                    icon = 'fas fa-key',
                    targeticon = 'fas fa-key',
                    action = function()
                        ChangeCode(labId)
                    end,
                    canInteract = function()
                        return lab.owner and lab.owner == FM.player.getIdentifier()
                    end,
                },
                {
                    label = 'Buy '..lab.name..' ($'..lab.price..')',
                    icon = 'fas fa-dollar-sign',
                    targeticon = 'fas fa-dollar-sign',
                    action = function()
                        OpenBuyLabDialog(labId)
                    end,
                    canInteract = function()
                        return not lab.owner
                    end,
                },
                {
                    label = 'Raid '..lab.name,
                    icon = 'fas fa-handcuffs',
                    targeticon = 'fas fa-handcuffs',
                    action = function()
                        RaidLab(labId)
                    end,
                    canInteract = function()
                        return Config.CopsRaid.enabled and CurrentJob and CurrentJob.name == Config.CopsRaid.allowedJob.name and CurrentJob.grade >= Config.CopsRaid.allowedJob.minGrade and lab.owner
                    end,
                }
            },
            distance = 2.5,
        })
    end
end

-- Gets used when ox_target and qb-target are not started
function OpenLabMenu(labId)
    local lab = Labs[labId]
    if not lab then return end

    local opts = {}
    
    if lab.owner and (lab.code or lab.lastraid) then
        opts[#opts+1] = {
            title = 'Enter '..lab.name,
            icon = 'fas fa-sign-in-alt',
            arrow = true,
            onSelect = function()
                EnterLab(labId)
            end,
        }
    end

    if lab.owner and lab.owner == FM.player.getIdentifier() then
        opts[#opts+1] = {
            title = 'Set Code',
            icon = 'fas fa-key',
            arrow = true,
            onSelect = function()
                ChangeCode(labId)
            end,
        }
    end

    if not lab.owner then
        opts[#opts+1] = {
            title = 'Buy '..lab.name..' ($'..lab.price..')',
            icon = 'fas fa-dollar-sign',
            arrow = true,
            onSelect = function()
                OpenBuyLabDialog(labId)
            end,
        }
    end

    if Config.CopsRaid.enabled and CurrentJob and CurrentJob.name == Config.CopsRaid.allowedJob.name and CurrentJob.grade >= Config.CopsRaid.allowedJob.minGrade and lab.owner then
        opts[#opts+1] = {
            title = 'Raid '..lab.name,
            icon = 'fas fa-handcuffs',
            arrow = true,
            onSelect = function()
                RaidLab(labId)
            end,
        }
    end

    lib.registerContext({
        id = 'labmenu'..tostring(labId),
        title = lab.name,
        options = opts,
    })

    lib.showContext('labmenu'..tostring(labId))
end

Last updated