📝Configurables

Config Files

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

Config = {}
-- Create plants in the config/plants/ folder
Config.Plants = {}

Config.Locale = 'en'
Config.SaveInterval = 10    -- Minutes (Set to 'false' to disable saving on interval, only on server shutdown)
Config.PaymentType = 'bank' -- Payment type for buying & upgrading stuff

--[[
    Make all kinds of custom actions to (re)use for a plant.
    To bind an action to a plant, go to the actions of your plant in the Config.Plants table and put the unique action name in this list.
--]]
Config.Actions = {                -- Make all kinds of custom actions to (re)use for a plant, you set these
    ['waterWithCan'] = {          -- Unique action
        label = 'Water',
        interval = 60,            --  Minutes before action can be done again
        onPlaceInterval = 30,      -- Minutes before action can be done for the first time (0 to immediately can/need to use action, maximum is interval)
        plantProgress = {
            increase = 10,        -- Increase plant progress when using this action (0-100)
            decrease = 5,         -- Decrease plant progress if action is not done after interval
            decreaseInterval = 30 -- Every x minutes the plant progress decreases if the action is not done when its ready to do
        },
        requiredItems = {
            { item = 'watering_can', label = 'Watering Can', amount = 1, remove = true },
        },
        progressBar = {
            enabled = true,
            label = 'Watering..',
            duration = 5000, -- Duration in milliseconds
            animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
        },
        ui = {
            color = 'sky',   -- 'sky' | 'rose' | 'amber'
            icon = 'bucket', -- 'bucket' | 'seedling' | 'sack' | 'droplet'
        },
        success = "You have watered the plant",
    },
    ['fertilize'] = {
        label = 'Fertilize',
        interval = 60,
        onPlaceInterval = 30,
        plantProgress = {
            increase = 10,
            decrease = 5,
            decreaseInterval = 30
        },
        requiredItems = {
            { item = 'fertilizer', label = 'Fertilizer', amount = 1, remove = true },
        },
        progressBar = {
            enabled = true,
            label = 'Fertilizing..',
            duration = 5000,
            animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
        },
        ui = {
            color = 'amber',
            icon = 'sack',
        },
        success = "You have fertilized the plant",
    },
    ['customAction'] = {
        label = 'Custom Action',
        interval = 60,
        onPlaceInterval = 30,
        plantProgress = {
            increase = 10,
            decrease = 5,
            decreaseInterval = 30
        },
        requiredItems = {
            -- { item = 'bread', label = 'Custom Item', amount = 1, remove = true },
        },
        progressBar = {
            enabled = true,
            label = 'Custom Actioning..',
            duration = 5000,
            animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
        },
        ui = {
            color = 'invalid_color_gets_gray',
            icon = 'droplet',
        },
        success = "You have executed a custom action",
    },
}

--[[
    Configure & customize all plots
--]]
Config.Plots = {
    ['Farmer Plot'] = {
        price = 50000,
        maxPlants = 10,
        allowedPlants = { 'Tomato' }, -- Allowed plants for this plot from config/plants/ folder
        upgrades = {
            plants = {
                { type = 'Cotton', price = 5000 },
                { type = 'Potato', price = 10000 },
            },
            maxPlants = {
                { amount = 20, price = 5000 },
                { amount = 30, price = 10000 },
            }
        },
        sellable = {
            enabled = true,
            price = 5000,
        },
        stash = {
            enabled = true,
            slots = 20,
            weight = 1000,
        },
        npc = {
            model = 'a_m_m_hillbilly_01',
            coords = vector3(2199.5732, 5197.5605, 60.0815),
            heading = 121.3640,
        },
        zone = {
            canShow = true, -- Zone can be shown at the npc
            thickness = 10,
            points = {      -- All z values must match
                vector3(2216.5903, 5174.9321, 60.0),
                vector3(2196.9011, 5195.4331, 60.0),
                vector3(2181.9851, 5204.6304, 60.0),
                vector3(2168.9219, 5210.4526, 60.0),
                vector3(2159.4966, 5212.4468, 60.0),
                vector3(2145.6890, 5211.6963, 60.0),
                vector3(2197.6438, 5154.3555, 60.0),
                vector3(2213.6431, 5170.1870, 60.0),
            },
        }
    },
    ['Drugs Plot'] = {
        price = 100000,
        maxPlants = 10,
        allowedPlants = { 'Weed', 'Poppy' }, -- Allowed plants for this plot from config/plants/ folder
        upgrades = {
            plants = {
                { type = 'Blue Weed', price = 5000 },
                { type = 'Purple Weed', price = 10000 },
                { type = 'Coca', price = 10000 },
            },
            maxPlants = {
                { amount = 20, price = 5000 },
                { amount = 30, price = 10000 },
            }
        },
        sellable = {
            enabled = true,
            type = 'bank',
            price = 5000,
        },
        stash = {
            enabled = true,
            slots = 20,
            weight = 1000,
        },
        npc = {
            model = 'g_m_m_armboss_01',
            coords = vector3(5404.3218, -5173.9409, 30.4826),
            heading = 89.9120,
        },
        zone = {
            canShow = true, -- Zone can be shown at the npc
            thickness = 10,
            points = {      -- All z values must match
                vector3(5398.9517, -5191.7437, 30.0),
                vector3(5429.2002, -5216.2227, 30.0),
                vector3(5411.8711, -5240.5015, 30.0),
                vector3(5380.2134, -5215.8584, 30.0),
            },
        }
    }
}

--[[
    Configure wild spawning
    Spawns random plants at random locations in their last stage to be harvested
--]]
Config.WildSpawning = {
    {
        plants = { 'Tomato', 'Potato', 'Cotton' }, -- Plants that can spawn at these locations
        limit = 1, -- How many plants can spawn at the same time (we recommend to set this like 1/2 of the total locations)
        locations = {
            vector4(819.2141, 6513.7358, 22.1483, 238.0658),
            vector4(814.9882, 6514.5430, 22.2471, 78.8440),
        },
    },
}

--[[
    INITIALIZATION SECTION

    DO NOT TOUCH THIS UNLESS YOU HAVE RENAMED fmLib, ox_target or qb-target

    IF YOU HAVE RENAMED A SCRIPT FROM ABOVE, UNCOMMENT THE LINE AND CHANGE THE NAME TO THE RIGHT SCRIPT NAME

    EXAMPLE:
    OXTarget = 'custom_script_name'
--]]

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

Opensource Files

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

function InitPlotTarget(plotName)
    local staticPlot = Plots[plotName]
    local pedEntity = staticPlot.ped

    if OXTarget then
        OXTarget:addLocalEntity(pedEntity, {
            {
                label = 'Buy Plot',
                name = 'buyPlotNPC',
                icon = 'fas fa-leaf',
                distance = 2.5,
                canInteract = function()
                    return not Plots[plotName].owner
                end,
                onSelect = function()
                    OpenBuyPlot(plotName)
                end,
            },
            {
                label = 'Manage Plot',
                name = 'managePlotNPC',
                icon = 'fas fa-leaf',
                distance = 2.5,
                canInteract = function()
                    return Plots[plotName] and Plots[plotName].owner == PlayerIdentifier
                end,
                onSelect = function()
                    OpenManagePlot(plotName)
                end,
            },
            {
                label = 'Sell Plot',
                name = 'sellPlotNPC',
                icon = 'fas fa-leaf',
                distance = 2.5,
                canInteract = function()
                    return Plots[plotName] and Plots[plotName].owner == PlayerIdentifier and Plots[plotName].sellable.enabled
                end,
                onSelect = function()
                    SellPlot(plotName)
                end,
            },
            {
                label = 'Toggle Zone',
                name = 'toggleZoneNPC',
                icon = 'fas fa-draw-polygon',
                distance = 2.5,
                canInteract = function()
                    return staticPlot.zone.canShow
                end,
                onSelect = function()
                    InitPlotZone(plotName)
                end,
            },
        })
    elseif QBTarget then
        QBTarget:AddTargetEntity(pedEntity, {
            options = {
                {
                    label = 'Buy Plot',
                    icon = 'fas fa-leaf',
                    canInteract = function()
                        return not Plots[plotName]
                    end,
                    action = function(data)
                        OpenBuyPlot(plotName)
                    end,
                },
                {
                    label = 'Manage Plot',
                    icon = 'fas fa-leaf',
                    canInteract = function()
                        return Plots[plotName] and Plots[plotName].owner == PlayerIdentifier
                    end,
                    action = function(data)
                        OpenManagePlot(plotName)
                    end,
                }
            },
            distance = 2.5
        })
    end
end

function InitPlantTarget(plantId, isWild)
    local plant = not isWild and Plants[plantId] or WildPlants[plantId]

    if OXTarget then
        OXTarget:addLocalEntity(plant.object, {
            {
                label = 'Manage ' .. plant.type,
                name = 'managePlant',
                icon = 'fas fa-leaf',
                distance = 2.5,
                canInteract = function()
                    return plant.owner == PlayerIdentifier and not isWild
                end,
                onSelect = function()
                    OpenManagePlant(plantId)
                end,
            },
            {
                label = 'Harvest ' .. plant.type,
                name = 'harvestPlant',
                icon = 'fas fa-leaf',
                distance = 2.5,
                canInteract = function()
                    return isWild
                end,
                onSelect = function()
                    HarvestPlant(plantId, true)
                end,
            }
        })
    elseif QBTarget then
        QBTarget:AddTargetEntity(plant.object, {
            options = {
                {
                    label = 'Manage Plant',
                    icon = 'fas fa-leaf',
                    canInteract = function()
                        return plant.owner == PlayerIdentifier and not isWild
                    end,
                    action = function(data)
                        OpenManagePlant(plantId)
                    end,
                },
                {
                    label = 'Harvest Plant',
                    icon = 'fas fa-leaf',
                    canInteract = function()
                        return isWild
                    end,
                    action = function(data)
                        HarvestPlant(plantId, true)
                    end,
                }
            },
            distance = 2.5
        })
    end
end

Last updated