All resources

rsg-farming – Docs (v3.1.0)#

Contents#

  1. Files
  2. How it works
  3. Configuration
  4. Events and commands
  5. Database
  6. Security
  7. Server owner how-tos
  8. Troubleshooting

1. Files#

FilePurpose
fxmanifest.luaManifest; depends on rsg-core, rsg-inventory, oxmysql, rsg-target, rsg-gizmo, rsg-wellpump
shared/config.luaLimits, growth, items, crops
client/client.luaPlant props, targets, tending UI, /myplants
client/utils.luaClient helpers (notify, busy guard, NUI focus + push-to-talk, rsg-gizmo wrapper, props)
server/server.luaPlants, growth simulation, tending, harvest
server/utils.luaServer helpers (items, ownership sync, action timers, database setup, item check)
server/versionchecker.luaGitHub version check
install.sqlManual database install (only when AutoDatabase = false)
html/NUI tending panel and plant list
stream/Custom weed props (prop_weed_01–06, textures, ytyp)
locales/*.jsonen, de, el, es, fr, ja, nl, pl, pt-br, ro, ru

2. How it works#

  • Use a seed item to place a ghost crop with rsg-gizmo (the server re-validates the result with IsPlacementValid).
  • The server simulates growth: water and fertiliser drain over time, health drops when dry, plants die if neglected.
  • Props change by growth stage (model and height offset per stage). Fertilised plants grow faster.
  • Tend a plant (rsg-target sphere zone, or G when UseTarget = false) to water, fertilise, harvest or remove it. The panel shows growth, water, fertiliser, health, status and time to harvest.
  • /myplants lists your crops nearest first with mini bars; click a far plant for a map route.
  • Water comes from buckets filled at rsg-wellpump pumps. A watering calls exports['rsg-wellpump']:UseBucket(src), which takes one use off the full bucket and returns an empty bucket when it runs out (default 5 uses, set in rsg-wellpump).
  • Seasons: the growth tick multiplies growth by Config.Seasons.months[os.date('%m')] (server real time). The server also sends each plant's eta (minutes to harvest) so the UI matches.
  • Rain: each growth tick reads GlobalState.rsgWeather.weather (set by rsg-weather) and adds Config.RainWater[weather] * minutes water to every plant. Regional weather translation on clients (snow, sandstorm) is not considered.
  • Pests (Config.Pests.enabled): infestations are in-memory only (cleared on restart). They slow growth, drain health and are cured with the Treat action (consumes Config.Pests.item).
  • XP: stored in player metadata farmingxp; XP is only awarded for actions on your own plants. Levels in Config.Levels give bonusYieldChance and extraPlants. Harvest bonus: plants at or above Config.Harvest.qualityHealth add qualityBonus to each produce reward (seeds excluded).
  • Only the planter can harvest or remove a living plant (OwnerOnlyHarvest); anyone can clear dead plants.

3. Configuration#

shared/config.lua:

OptionDefaultMeaning
DebugfalseDebug prints
Seasons, RainWater, Pests, TreatTime, Harvest, XP, Levelssee configSeasons, rain, pests, harvest quality and farming levels (see README configuration table)
AutoDatabasetrueCreate tables on start; false = import install.sql manually
NoPlantZones{}{ coords = vector3, radius } areas where planting is blocked (client preview + server check)
AllowPushToTalkWhileOpen / PushToTalkControlstrue / { 0x4BC9DABB }Keep push-to-talk working while the tending UI is open
MaxPlantsPerPlayer20Active plants per character
MinPlantDistance1.2Distance between plants
PlaceMaxDistance6.0Gizmo placement range
CollisionModel, CollisionPropsInvisible blocker for props without collision
InteractDistance1.6Tend range
RenderDistance60.0Prop spawn/despawn range
OwnerOnlyHarvesttrueOnly the planter can harvest/destroy
InteractKey, UseTarget, TargetRadius, TargetIconG, true, 0.8Interaction
TickInterval / SaveInterval30 / 120Seconds between growth ticks / saves
WaterDecay / FertilizerDecay100/60 / 100/90Loss per minute
MinWaterToGrow1Water needed to grow
FertilizerBoost1.5Growth multiplier when fertilised
DryDamage / HealthRegen5 / 2Health per minute
DeadPlantRemoveTime30Minutes before dead plants are removed
WaterItem / WaterAmountfullbucket / 100Watering (WaterItem must match rsg-wellpump's Config.FullItem)
FertilizerItem / FertilizerAmountfertilizer / 100Fertilising
PlantTime, WaterTime, FertilizeTime, HarvestTimemsAction durations
ScenariostableAnimations per action
Cropstablecorn, carrot, tomato, potato, tobacco, cotton, sugarcane, wheat, weed

Crop entry:

corn = {
    label = 'Corn', seed = 'seedcorn', growTime = 45, -- minutes to 100%
    stages = { { from = 0, prop = 'crp_cornstalks_bc_sim', zOffset = -1.4 }, { from = 100, prop = 'crp_cornstalks_bc_sim', zOffset = 0.0 } },
    harvest = { { item = 'corn', min = 2, max = 4 }, { item = 'seedcorn', min = 0, max = 1 } },
},

4. Events and commands#

NameSideNotes
rsg-farming:client:syncclient event(plants, mineIds) full plant sync (every growth tick and on login)
rsg-farming:client:plantUpdateclient event(plant) one plant changed (planted, watered, fertilised)
rsg-farming:client:plantRemoveclient event(id) a plant was harvested, removed or died off
rsg-farming:server:treatcallback(plantId) treat pests (validated + action timer)
rsg-farming:client:plantMineclient event(id) sent to the planter so they know they own the new plant
rsg-farming:client:startPlacingclient event(cropKey) start the placement gizmo
CommandWhoWhat
/myplantseveryoneList your crops
/farmleveleveryoneShow your farming level and XP

Seed items are registered as useable items automatically.

5. Database#

Created automatically on start while Config.AutoDatabase = true. To install manually set it to false and import install.sql (same schema):

  • rsg_farming_plants: id, citizenid, crop, x, y, z, h, growth, water, fertilizer, health, dead, dead_time, planted_at. Plants survive restarts; dead plants are removed automatically. Well pumps are stored by rsg-wellpump (rsg_wellpumps). The old rsg_farming_wellpumps table is no longer created or used; rsg-wellpump imports its rows once and leaves it untouched.

6. Security#

The server owns growth, water, fertiliser and health, checks ownership, distance, item possession and plant limits, and handles harvest rewards (dropping overflow if the inventory is full). Clients only request actions.

  • Placement: the client result from rsg-gizmo is untrusted; the server runs IsPlacementValid, spacing, per-player limit and NoPlantZones checks before taking the seed.
  • Ownership: clients never receive citizenids. Each player is sent the list of plant ids they own and nothing else.
  • Timed actions: the server starts a timer at the pre-check and only accepts the action after about 80% of the duration has passed.
  • Items: seeds and buckets are only removed after validation; if a refund or reward no longer fits it is dropped at the player's feet, never lost.
  • Other scripts should not write to the rsg_farming_* tables directly.

7. How-tos#

  • New crop: add an entry to Config.Crops, then add the seed and harvest items.
  • Items needed: seeds, fullbucket, bucket, fertilizer (plus pesticide if Config.Pests.enabled = true).
  • Language: setr rsg:locale "de" in server.cfg.

8. Troubleshooting#

ProblemFix
Plant won't growNeeds water above MinWaterToGrow
Plant diedIt dried out; dead plants clear after DeadPlantRemoveTime
Can't harvestNot your plant while OwnerOnlyHarvest = true, or not fully grown
Weed props invisibleKeep the stream/ folder with the resource
Pests never go awayEnable Config.Pests, add the pesticide item, and use the Treat button on the plant
Rain doesn't water plantsrsg-weather must be running and report a weather name listed in Config.RainWater
Water does nothing / "no water"rsg-wellpump must be started before rsg-farming, and Config.WaterItem must match its Config.FullItem
rsg-gizmo errors on startEnsure rsg-gizmo starts before rsg-farming
Console warns about missing itemsAdd the listed items to rsg-core/shared/items.lua
Can't plant in a townA Config.NoPlantZones entry covers it
Water bucket always has 5 usesMake fullbucket a unique = true item so its remaining uses are kept per bucket

rsg-skills integration#

Config.Skills = { Enabled, Skill, XPScale, LevelsPerExtraPlant }. A local useSkills() is true when enabled and GetResourceState('rsg-skills') == 'started'; the check is made on each call, so a restart of rsg-skills switches modes live.

  • addXP calls exports['rsg-skills']:AddXP(src, 'farming', amount * XPScale, 'farming') and returns early (no metadata XP, no built-in level-up notification).
  • perkOf returns bonusYieldChance = GetPerk(src, 'farming', 'extra_yield') and extraPlants = floor((level - 1) / LevelsPerExtraPlant), which feed the harvest roll and maxPlantsFor.
  • /farmlevel uses GetProgress and the locale keys level_info_skills and level_info_skills_next (added to all locale files).
  • The speed_bonus perk is not used by this script.

Support the Project : https://rexshack.tebex.store/

<!-- BEGIN AUTO-REFERENCE (generated from the code; re-run the generator instead of editing by hand) -->

Technical reference#

Generated from the source of rsg-farming 3.2.0. Names, arguments and defaults below are read straight from the code.

Dependencies#

rsg-core, rsg-inventory, oxmysql, rsg-target, rsg-gizmo

Database#

Tables: rsg_farming_plants.

Tables are created automatically on start while Config.AutoDatabase = true (default). Nothing is ever dropped or overwritten. For a manual install set Config.AutoDatabase = false and import install.sql once.

-- shared/config.lua
Config.AutoDatabase = true -- false = import the SQL file yourself

Configuration#

OptionDefaultNotes
Config.Debugfalse
Config.AutoDatabasetruecreate the tables on start; set false and import install.sql manually
Config.MaxPlantsPerPlayer20max active plants per character
Config.MinPlantDistance1.2min distance between two plants
Config.PlaceMaxDistance6.0how far from the player the gizmo can place
Config.NoPlantZones{}Config.NoPlantZones = { { coords = vector3(0.0, 0.0, 0.0), radius = 150.0 } }
Config.AllowPushToTalkWhileOpentruewhile the tending UI is open, block game controls but keep push-to-talk working
Config.PushToTalkControlstable
Config.CollisionModel'p_emrfencepost02x'custom props with no collision: an invisible blocker is spawned with them (and removed with them)
Config.CollisionPropstable
Config.InteractDistance1.6distance to tend a plant
Config.RenderDistance60.0props spawn / despawn distance
Config.OwnerOnlyHarvesttrueonly the planter can harvest / destroy
Config.InteractKey0x760A9C6F[G] (only used when UseTarget = false)
Config.UseTargettrueuse rsg-target zones on plants instead of the [G] prompt
Config.TargetRadius0.8sphere zone radius around each plant
Config.TargetIcon'fa-solid fa-seedling'
Config.TickInterval30seconds between growth ticks
Config.SaveInterval120seconds between DB saves
Config.WaterDecay100 / 60water lost per minute (100 -> 0 in 60 min)
Config.FertilizerDecay100 / 90fertiliser lost per minute
Config.MinWaterToGrow1plant only grows if water above this
Config.FertilizerBoost1.5growth multiplier while fertilised
Config.DryDamage5health lost per minute with no water
Config.HealthRegen2health gained per minute while watered
Config.DeadPlantRemoveTime30minutes before a dead plant is auto-removed
Config.WaterItem'fullbucket'consumed when watering
Config.WaterAmount100water added (capped at 100)
Config.FertilizerItem'fertilizer'
Config.FertilizerAmount100
Config.Seasonstable
Config.RainWatertable
Config.Peststable
Config.Harvesttable
Config.XP{ enabled = true, plant = 2, water = 1, fertilize = 1, treat = 1, harv
Config.Levelstable
Config.PlantTime6000
Config.WaterTime5000
Config.FertilizeTime5000
Config.TreatTime5000
Config.HarvestTime7000
Config.Scenariostable
Config.Cropstable
Config.Skillstableslot. The Config.XP / Config.Levels above are used when rsg-skills is missing or Enabled = false.
Config.Enabledtrue
Config.Skill'farming'
Config.XPScale1
Config.LevelsPerExtraPlant3

Events#

Server events can be fired by any client, so every handler re-validates the player, the arguments and any permission, distance or cooldown on the server. Never add a reward to a handler without those checks.

EventSideArgumentsFile
rsg-farming:client:syncclient``client/client.lua
rsg-farming:client:plantUpdateclientpclient/client.lua
rsg-farming:client:plantRemoveclientidclient/client.lua
rsg-farming:client:plantMineclientidclient/client.lua
RSGCore:Client:OnPlayerLoadedclient``client/client.lua
RSGCore:Client:OnPlayerUnloadclient``client/client.lua
rsg-farming:client:startPlacingclientcropKeyclient/client.lua
-- from a server script
TriggerClientEvent('rsg-farming:client:sync', source)

Commands#

CommandNotesFile
/myplantsclient/client.lua
/farmlevelShow your farming levelserver/server.lua

Locales#

Language files in locales/: de, el, en, es, fr, ja, nl, pl, pt-br, ro, ru. Set the language with setr rsg:locale "en".

<!-- END AUTO-REFERENCE -->