Plantation
Configurables
All config & open sourced files included within this script.
Config Files
--[[
BY RX Scripts © rxscripts.xyz
--]]
Config = {}
-- Create plants in the config/plants/ folder
Config.Plants = {}
Config.DiscordWebhook = ''
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
Config.DistanceBetween = 2.5 -- Minimum distance between plants
Config.PublicAccessFreePlanted = false -- Allow everyone to access & manage a freely planted plant (without plot)
Config.MaxFreePlants = 5 -- Maximum amount of plants a player can plant without a plot
Config.CreatePlantsDistance = 100.0 -- Distance to be nearby for plants to be created
Config.CreatePlantsWait = 1000 -- Wait time in ms for checking distance to create plants
--[[
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 = 0, -- 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' },
prop = {
-- model = 'prop_wateringcan',
-- position = vector3(0.0, 0.0, 0.0),
-- rotation = vector3(0.0, 0.0, 0.0),
-- bone = 60309,
},
},
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' },
prop = {
-- model = 'prop_wateringcan',
-- position = vector3(0.0, 0.0, 0.0),
-- rotation = vector3(0.0, 0.0, 0.0),
-- bone = 60309,
},
},
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' },
prop = {
-- model = 'prop_wateringcan',
-- position = vector3(0.0, 0.0, 0.0),
-- rotation = vector3(0.0, 0.0, 0.0),
-- bone = 60309,
},
},
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,
payWithItem = {
enabled = false, -- If enabled, the price above is the amount of the item below you need to pay, instead of money
currency = { item = 'gold', label = 'Gold' },
},
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 },
}
},
farmers = { -- Members that can be added to the plot to work together
enabled = true,
max = 1,
},
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,
payWithItem = {
enabled = false, -- If enabled, the price above is the amount of the item below you need to pay, instead of money
currency = { item = 'gold', label = 'Gold' },
},
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 },
}
},
farmers = {
enabled = true,
max = 2,
},
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),
},
},
}
--[[
ONLY CHANGE THIS PART IF YOU HAVE RENAMED SCRIPTS SUCH AS FRAMEWORK, TARGET, INVENTORY ETC
RENAME THE SCRIPT NAME TO THE NEW NAME
--]]
---@type table Only change these if you have changed the name of a resource
Resources = {
FM = { name = 'fmLib', export = 'new' },
OXTarget = { name = 'ox_target', export = 'all' },
QBTarget = { name = 'qb-target', export = 'all' },
}
IgnoreScriptFoundLogs = false
Config.Plants['Coca'] = { -- Unique plant
placeItem = 'coca_seed', -- Usable item to place the plant
placeDuration = 3000, -- Duration in milliseconds for planting (0 is instant planting)
shouldDie = true, -- Plant dies if progress decreases to lower than current plant stage required progress
anywhere = false, -- Plant can be placed anywhere (ignores plots)
requiredItems = { -- Required items for planting
{ item = 'shovel', label = 'Shovel', amount = 1, remove = false },
},
actions = { -- Actions from Config.Actions
'waterWithCan',
'fertilize',
'customAction',
},
soil = {
required = true, -- Should the plant be placed on specific soil types
allowed = { -- Get soil types with /getsoiltype (takes it for 1m in front of ur character)
1109728704,
-1942898710,
},
},
stages = {
[1] = { -- Gets planted on using the placeItem
prop = 'coca_plant_1', -- First prop that gets placed
requiredProgress = 0, -- Required progress (always 0 for first stage)
harvest = {
enabled = true, -- Enable harvesting
duration = 1000, -- Duration in milliseconds, set to 0 for instant harvesting
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = { -- Rewards for harvesting
{ item = 'coca_seed', min = 0, max = 1 },
},
},
},
[2] = {
prop = 'coca_plant_2',
requiredProgress = 50, -- Required progress to reach this stage
harvest = {
enabled = true,
duration = 1000,
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = {
{ item = 'coca_seed', min = 1, max = 2 },
{ item = 'coca_leaf', min = 1, max = 2 },
},
}
},
[3] = {
prop = 'coca_plant_3',
requiredProgress = 100, -- Required progress (always 100 for last stage)
harvest = {
enabled = true, -- Enable harvesting
duration = 1000,
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = {
{ item = 'coca_seed', min = 3, max = 5 },
{ item = 'coca_leaf', min = 3, max = 5 },
},
}
}
}
}
Config.Plants['Cotton'] = { -- Unique plant
placeItem = 'cotton_seed', -- Usable item to place the plant
placeDuration = 3000, -- Duration in milliseconds for planting (0 is instant planting)
shouldDie = true, -- Plant dies if progress decreases to lower than current plant stage required progress
anywhere = false, -- Plant can be placed anywhere (ignores plots)
requiredItems = { -- Required items for planting
{ item = 'shovel', label = 'Shovel', amount = 1, remove = false },
},
actions = { -- Actions from Config.Actions
'waterWithCan',
'fertilize',
'customAction',
},
soil = {
required = true, -- Should the plant be placed on specific soil types
allowed = { -- Get soil types with /getsoiltype (takes it for 1m in front of ur character)
1109728704,
-1942898710,
},
},
stages = {
[1] = { -- Gets planted on using the placeItem
prop = 'plant_cotton_1', -- First prop that gets placed
requiredProgress = 0, -- Required progress (always 0 for first stage)
harvest = {
enabled = true, -- Enable harvesting
duration = 1000, -- Duration in milliseconds, set to 0 for instant harvesting
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = { -- Rewards for harvesting
{ item = 'cotton_seed', min = 0, max = 1 },
},
},
},
[2] = {
prop = 'plant_cotton_2',
requiredProgress = 50, -- Required progress to reach this stage
harvest = {
enabled = true,
duration = 1000,
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = {
{ item = 'cotton_seed', min = 1, max = 2 },
{ item = 'cotton', min = 1, max = 2 },
},
}
},
[3] = {
prop = 'plant_cotton_3',
requiredProgress = 100, -- Required progress (always 100 for last stage)
harvest = {
enabled = true, -- Enable harvesting
duration = 1000,
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = {
{ item = 'cotton_seed', min = 3, max = 5 },
{ item = 'cotton', min = 3, max = 5 },
},
}
}
}
}
Config.Plants['Poppy'] = { -- Unique plant
placeItem = 'poppy_seed', -- Usable item to place the plant
placeDuration = 3000, -- Duration in milliseconds for planting (0 is instant planting)
shouldDie = true, -- Plant dies if progress decreases to lower than current plant stage required progress
anywhere = false, -- Plant can be placed anywhere (ignores plots)
requiredItems = { -- Required items for planting
{ item = 'shovel', label = 'Shovel', amount = 1, remove = false },
},
actions = { -- Actions from Config.Actions
'waterWithCan',
'fertilize',
'customAction',
},
soil = {
required = true, -- Should the plant be placed on specific soil types
allowed = { -- Get soil types with /getsoiltype (takes it for 1m in front of ur character)
1109728704,
-1942898710,
},
},
stages = {
[1] = { -- Gets planted on using the placeItem
prop = 'plant_poppy_1', -- First prop that gets placed
requiredProgress = 0, -- Required progress (always 0 for first stage)
harvest = {
enabled = true, -- Enable harvesting
duration = 1000, -- Duration in milliseconds, set to 0 for instant harvesting
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = { -- Rewards for harvesting
{ item = 'poppy_seed', min = 0, max = 1 },
},
},
},
[2] = {
prop = 'plant_poppy_2',
requiredProgress = 50, -- Required progress to reach this stage
harvest = {
enabled = true,
duration = 1000,
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = {
{ item = 'poppy_seed', min = 1, max = 2 },
{ item = 'poppy_opium', min = 1, max = 2 },
},
}
},
[3] = {
prop = 'plant_poppy_3',
requiredProgress = 100, -- Required progress (always 100 for last stage)
harvest = {
enabled = true, -- Enable harvesting
duration = 1000,
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = {
{ item = 'poppy_seed', min = 3, max = 5 },
{ item = 'poppy_opium', min = 3, max = 5 },
},
}
}
}
}
Config.Plants['Potato'] = { -- Unique plant
placeItem = 'potato_seed', -- Usable item to place the plant
placeDuration = 3000, -- Duration in milliseconds for planting (0 is instant planting)
shouldDie = true, -- Plant dies if progress decreases to lower than current plant stage required progress
anywhere = false, -- Plant can be placed anywhere (ignores plots)
requiredItems = { -- Required items for planting
{ item = 'shovel', label = 'Shovel', amount = 1, remove = false },
},
actions = { -- Actions from Config.Actions
'waterWithCan',
'fertilize',
'customAction',
},
soil = {
required = true, -- Should the plant be placed on specific soil types
allowed = { -- Get soil types with /getsoiltype (takes it for 1m in front of ur character)
1109728704,
-1942898710,
},
},
stages = {
[1] = { -- Gets planted on using the placeItem
prop = 'plant_potatoe_1', -- First prop that gets placed
requiredProgress = 0, -- Required progress (always 0 for first stage)
harvest = {
enabled = true, -- Enable harvesting
duration = 1000, -- Duration in milliseconds, set to 0 for instant harvesting
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = { -- Rewards for harvesting
{ item = 'potato_seed', min = 0, max = 1 },
},
},
},
[2] = {
prop = 'plant_potatoe_2',
requiredProgress = 50, -- Required progress to reach this stage
harvest = {
enabled = true,
duration = 1000,
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = {
{ item = 'potato_seed', min = 1, max = 2 },
{ item = 'potato', min = 1, max = 2 },
},
}
},
[3] = {
prop = 'plant_potatoe_3',
requiredProgress = 100, -- Required progress (always 100 for last stage)
harvest = {
enabled = true, -- Enable harvesting
duration = 1000,
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = {
{ item = 'potato_seed', min = 3, max = 5 },
{ item = 'potato', min = 3, max = 5 },
},
}
}
}
}
Config.Plants['Tomato'] = { -- Unique plant
placeItem = 'tomato_seed', -- Usable item to place the plant
placeDuration = 3000, -- Duration in milliseconds for planting (0 is instant planting)
shouldDie = true, -- Plant dies if progress decreases to lower than current plant stage required progress
anywhere = true, -- Plant can be placed anywhere (ignores plots)
requiredItems = { -- Required items for planting
{ item = 'shovel', label = 'Shovel', amount = 1, remove = false },
},
actions = { -- Actions from Config.Actions
'waterWithCan',
'fertilize',
'customAction',
},
soil = {
required = true, -- Should the plant be placed on specific soil types
allowed = { -- Get soil types with /getsoiltype (takes it for 1m in front of ur character)
1109728704,
-1942898710,
},
},
stages = {
[1] = { -- Gets planted on using the placeItem
prop = 'plant_tomatoe_1', -- First prop that gets placed
requiredProgress = 0, -- Required progress (always 0 for first stage)
harvest = {
enabled = true, -- Enable harvesting
duration = 1000, -- Duration in milliseconds, set to 0 for instant harvesting
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = { -- Rewards for harvesting
{ item = 'tomato_seed', min = 0, max = 1 },
},
},
},
[2] = {
prop = 'plant_tomatoe_2',
requiredProgress = 50, -- Required progress to reach this stage
harvest = {
enabled = true,
duration = 1000,
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = {
{ item = 'tomato_seed', min = 1, max = 2 },
{ item = 'tomato', min = 1, max = 2 },
},
}
},
[3] = {
prop = 'plant_tomatoe_3',
requiredProgress = 100, -- Required progress (always 100 for last stage)
harvest = {
enabled = true, -- Enable harvesting
duration = 1000,
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = {
{ item = 'tomato_seed', min = 3, max = 5 },
{ item = 'tomato', min = 3, max = 5 },
},
}
}
}
}
Config.Plants['Blue Weed'] = { -- Unique plant
placeItem = 'weed_seed_blue', -- Usable item to place the plant
placeDuration = 3000, -- Duration in milliseconds for planting (0 is instant planting)
shouldDie = true, -- Plant dies if progress decreases to lower than current plant stage required progress
anywhere = false, -- Plant can be placed anywhere (ignores plots)
requiredItems = { -- Required items for planting
{ item = 'shovel', label = 'Shovel', amount = 1, remove = false },
},
actions = { -- Actions from Config.Actions
'waterWithCan',
'fertilize',
'customAction',
},
soil = {
required = true, -- Should the plant be placed on specific soil types
allowed = { -- Get soil types with /getsoiltype (takes it for 1m in front of ur character)
1109728704,
-1942898710,
},
},
stages = {
[1] = { -- Gets planted on using the placeItem
prop = 'plant_weed_1_blue', -- First prop that gets placed
requiredProgress = 0, -- Required progress (always 0 for first stage)
harvest = {
enabled = true, -- Enable harvesting
duration = 1000, -- Duration in milliseconds, set to 0 for instant harvesting
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = { -- Rewards for harvesting
{ item = 'weed_seed_blue', min = 0, max = 1 },
},
},
},
[2] = {
prop = 'plant_weed_2_blue',
requiredProgress = 50, -- Required progress to reach this stage
harvest = {
enabled = true,
duration = 1000,
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = {
{ item = 'weed_seed_blue', min = 1, max = 2 },
{ item = 'weed_leaf_blue', min = 1, max = 2 },
},
}
},
[3] = {
prop = 'plant_weed_3_blue',
requiredProgress = 100, -- Required progress (always 100 for last stage)
harvest = {
enabled = true, -- Enable harvesting
duration = 1000,
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = {
{ item = 'weed_seed_blue', min = 3, max = 5 },
{ item = 'weed_leaf_blue', min = 3, max = 5 },
},
}
}
}
}
Config.Plants['Purple Weed'] = { -- Unique plant
placeItem = 'weed_seed_purple', -- Usable item to place the plant
placeDuration = 3000, -- Duration in milliseconds for planting (0 is instant planting)
shouldDie = true, -- Plant dies if progress decreases to lower than current plant stage required progress
anywhere = false, -- Plant can be placed anywhere (ignores plots)
requiredItems = { -- Required items for planting
{ item = 'shovel', label = 'Shovel', amount = 1, remove = false },
},
actions = { -- Actions from Config.Actions
'waterWithCan',
'fertilize',
'customAction',
},
soil = {
required = true, -- Should the plant be placed on specific soil types
allowed = { -- Get soil types with /getsoiltype (takes it for 1m in front of ur character)
1109728704,
-1942898710,
},
},
stages = {
[1] = { -- Gets planted on using the placeItem
prop = 'plant_weed_1_purple', -- First prop that gets placed
requiredProgress = 0, -- Required progress (always 0 for first stage)
harvest = {
enabled = true, -- Enable harvesting
duration = 1000, -- Duration in milliseconds, set to 0 for instant harvesting
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = { -- Rewards for harvesting
{ item = 'weed_seed_purple', min = 0, max = 1 },
},
},
},
[2] = {
prop = 'plant_weed_2_purple',
requiredProgress = 50, -- Required progress to reach this stage
harvest = {
enabled = true,
duration = 1000,
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = {
{ item = 'weed_seed_purple', min = 1, max = 2 },
{ item = 'weed_leaf_purple', min = 1, max = 2 },
},
}
},
[3] = {
prop = 'plant_weed_3_purple',
requiredProgress = 100, -- Required progress (always 100 for last stage)
harvest = {
enabled = true, -- Enable harvesting
duration = 1000,
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = {
{ item = 'weed_seed_purple', min = 3, max = 5 },
{ item = 'weed_leaf_purple', min = 3, max = 5 },
},
}
}
}
}
Config.Plants['Weed'] = { -- Unique plant
placeItem = 'weed_seed', -- Usable item to place the plant
placeDuration = 3000, -- Duration in milliseconds for planting (0 is instant planting)
shouldDie = true, -- Plant dies if progress decreases to lower than current plant stage required progress
anywhere = true, -- Plant can be placed anywhere (ignores plots)
requiredItems = { -- Required items for planting
{ item = 'shovel', label = 'Shovel', amount = 1, remove = false },
},
actions = { -- Actions from Config.Actions
'waterWithCan',
'fertilize',
'customAction',
},
soil = {
required = true, -- Should the plant be placed on specific soil types
allowed = { -- Get soil types with /getsoiltype (takes it for 1m in front of ur character)
1109728704,
-1942898710,
},
},
stages = {
[1] = { -- Gets planted on using the placeItem
prop = 'plant_weed_1', -- First prop that gets placed
requiredProgress = 0, -- Required progress (always 0 for first stage)
harvest = {
enabled = true, -- Enable harvesting
duration = 1000, -- Duration in milliseconds, set to 0 for instant harvesting
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = { -- Rewards for harvesting
{ item = 'weed_seed', min = 0, max = 1 },
},
},
},
[2] = {
prop = 'plant_weed_2',
requiredProgress = 50, -- Required progress to reach this stage
harvest = {
enabled = true,
duration = 1000,
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = {
{ item = 'weed_seed', min = 1, max = 2 },
{ item = 'weed_leaf', min = 1, max = 2 },
},
}
},
[3] = {
prop = 'plant_weed_3',
requiredProgress = 100, -- Required progress (always 100 for last stage)
harvest = {
enabled = true, -- Enable harvesting
duration = 1000,
animation = { dict = 'amb@world_human_gardener_plant@male@base', anim = 'base' },
rewards = {
{ item = 'weed_seed', min = 3, max = 5 },
{ item = 'weed_leaf', min = 3, max = 5 },
},
}
}
}
}
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 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].owner
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,
},
{
label = 'Sell Plot',
icon = 'fas fa-leaf',
canInteract = function()
return Plots[plotName] and Plots[plotName].owner == PlayerIdentifier and Plots[plotName].sellable.enabled
end,
action = function(data)
SellPlot(plotName)
end,
},
{
label = 'Toggle Zone',
icon = 'fas fa-draw-polygon',
canInteract = function()
return staticPlot.zone.canShow
end,
action = function(data)
InitPlotZone(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()
if isWild then return false end
if not plant.plot and Config.PublicAccessFreePlanted then return true end
local plot = Plots[plant.plot]
if plant.plot and plot then
local cfgPlot = Config.Plots[plant.plot]
if cfgPlot and cfgPlot.farmers and cfgPlot.farmers.enabled then
if plot.members[PlayerIdentifier] then return true end
if plot.owner == PlayerIdentifier then return true end
end
end
if plant.owner == PlayerIdentifier then return true end
return false
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()
if isWild then return false end
if not plant.plot and Config.PublicAccessFreePlanted then return true end
if plant.plot and Plots[plant.plot] then
local cfgPlot = Config.Plots[plant.plot]
if cfgPlot and cfgPlot.farmers and cfgPlot.farmers.enabled then
if Plots[plant.plot].members[PlayerIdentifier] then return true end
end
end
if plant.owner == PlayerIdentifier then return true end
return false
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
--[[
BY RX Scripts © rxscripts.xyz
--]]
-- Custom can buy check function u can integrate custom checks
---@param playerId number Id/Source of the player
---@param plot table Plot object
---@return boolean, string?
function CanBuyPlot(playerId, plot)
return true
-- return false, 'You cannot buy this lab because of..'
end