Skip to content

Installation ​

Requirements ​

  • A recent FiveM server artifact (Lua 5.4) with OneSync turned on (the server checks positions from its own ped, and tractors are sampled on the server)
  • oxmysql
  • np_npchandler and np_prophandler, both 1.1.0+, started before np_farming. Every ped (buyers, pen animals, the truffle pig, crows) and every prop (plants, pots, stations, hives, pens, water barrels, threat props, the placement ghost, the tool in your hand) goes through them
  • Node 18+ to build the NUI once (web/dist is the build output and isn't in the repository)

Optional, auto-detected at start (each with a fallback, see Integrations & compatibility):

Kind Resources Without it
Framework es_extended (best-tested), qbx_core, qb-core Standalone: license or np_character identifiers, jobs from Config.StandaloneJobs, no economy
Inventory np_inventory (best-tested), ox_inventory, qb-inventory (and forks with the same exports), the default ESX inventory none: no items
Staff np_admin, np_discord Framework admin groups and Config.Admins (see Admin)
Weather Renewed-Weathersync, qb-weathersync, cd_easytime, vSync np_admin's or np_menu's world tool, else np_farming's own seasonal cycle
Shift clock md-stempeluhr (MDT) over HTTP No farm shifts
Dispatch ps-dispatch, cd_dispatch, qs-dispatch, core_dispatch A toast and a blip for police and fire on duty
Other np_* siblings np_hud, np_menu, np_phone, np_shops, np_banking, … A built-in fallback for each
Zones np_colshape Distance checks instead of colshapes for enter and exit of the world points, and the truffle forest zones on the server. Needed on FiveM Legacy only, GTAV Enhanced has the natives built in

Steps ​

  1. Put the folder into your resources as np_farming. The NUI calls https://np_farming/rpc, item definitions call np_farming.useItem and other resources call exports.np_farming, so keep the name.
  2. Start order in server.cfg. The framework and the inventory are detected once, at start:
    cfg
    ensure oxmysql
    ensure es_extended          # or qbx_core / qb-core
    ensure np_inventory         # or ox_inventory / qb-inventory
    ensure np_prophandler
    ensure np_npchandler
    ensure np_admin             # optional: staff rights, settings, audit log, staff tools
    ensure np_hud               # optional siblings, any order
    ensure np_menu
    ensure np_phone
    ensure np_shops
    ensure np_farming
  3. Database: the tables (prefixed np_farming_) are created at start (Config.AutoCreateTables = true). To create them by hand instead, import sql/install.sql and then every sql/<module>.sql (below).
  4. Items (below): nothing to do on np_inventory; paste or import the generated lists on ox_inventory, qb-core / qbx_core and the ESX inventory.
  5. Jobs: map your farm, police and fire job names in Config.Jobs (below).
  6. Shift clock (optional): set the md-stempeluhr convars (below).
  7. Price board (optional): give your server a public base URL (web_baseUrl, which the cfx.re proxy sets for you) if you want the produce price page on an np_screens screen (Integrations).
  8. Start the server and read the start-up lines: one per bridge, one per optional sibling (active, fallback: …, missing export <name>, off in config, not running), the weather source and any missing items. npfarming_status prints them again.

Items ​

np_farming builds every item from its registry: tools and soil care from shared/config/items.lua, a seed and a produce item for every crop of Config.Crops, and the items each module adds from its own config file. The generated lists in integrations/install/ cover 71 items (139 on the ESX inventory, which needs one item per star).

Inventory What to do
np_inventory Nothing. Items are registered at runtime, with tints, durability for tools, categories and quality metadata, and again whenever np_inventory restarts
ox_inventory Paste integrations/install/ox_inventory_items.txt into ox_inventory/data/items.lua (inside the returned table). Copy integrations/install/images/*.png into ox_inventory/web/images/
qb-core / qbx_core Paste integrations/install/qb_core_items.txt into qb-core/shared/items.lua (or qbx_core/shared/items.lua). Copy the images into qb-inventory/html/images/
Default ESX inventory Import integrations/install/esx_items.sql. It includes the _q2 / _q3 quality items (tomato_q2, tomato_q3)

Used items call np_farming.useItem (server = { export = 'np_farming.useItem' } on ox; useable = true on qb).

The files are generated from the item registry. After you add crops or switch modules, write them again from the server console:

npfarming_install ox|qb|esx|np    # writes the item lists and the image list to integrations/install/
npfarming_items ox|qb|esx         # prints one list to the console instead

The start-up status names any item the inventory does not know. integrations/install/item_images.txt lists every picture the items look for (with the glyph and tint shown when it is missing); node integrations/install/make-images.mjs renders the item tiles again with headless Chrome.

Item pictures in np_farming's own screens are <Config.ImagePath><item>.png (default nui://np_inventory/web/images/). A missing picture falls back to a drawing or the item's glyph. On np_inventory, Config.Compat.inventory.images = true shows np_farming's rendered tiles instead of np_inventory's glyph tile.

Jobs ​

Config.Jobs (shared/config.lua) maps a job group to job names with a minimum grade:

lua
Config.Jobs = {
  farmer = { farmer = 0 },
  police = { police = 0, sheriff = 0 },
  fire = { fire = 0, firefighter = 0 },
}
Group Used for
farmer Job-only plots and stations (job = 'farmer', the cheese cellar by default), co-op stations without the co-op module
police Theft alarms from the farm camera ("Call 911", Config.Threats.theft.alertJob)
fire Field fire alerts (Config.Threats.fire.alertJob)

Standalone servers map identifiers (or np_character ids) to jobs in Config.StandaloneJobs. Jobs are not staff; staff rights are on Admin.

Shift clock (md-stempeluhr) ​

Co-op members clock farm shifts with /farmshift over md-stempeluhr's HTTP API. Set the convars with set (never setr):

cfg
set np_farming_stempeluhr_url "https://mdt.example.com"   # with or without the /api/v1 suffix
set np_farming_stempeluhr_key "<api key>"

The connection is checked once at start (read only, Config.Stempeluhr.probe). Without the convars there is no shift clock and everything else works.

Weather (vSync) ​

Renewed-Weathersync, qb-weathersync and cd_easytime are read as they are. vSync keeps its clock local to vs_server.lua, so append integrations/install/vsync_server.txt inside vSync/vs_server.lua (at the end of that file). It publishes GlobalState.npFarmingVSync every 2 seconds. See Configuration → World for the order of the weather sources.

Tables ​

Core tables (sql/install.sql):

Table Holds
np_farming_migrations Applied migrations
np_farming_kv Module state (key-value, one scope per module; tool wear without metadata)
np_farming_timers Timers that survive restarts (plot rent, station batches, contract due dates)
np_farming_players Farmer XP, level and stats
np_farming_payouts Money owed to offline payees (kept Config.Money.payoutDays)
np_farming_log The log

Module tables, one file each: sql/plots.sql (np_farming_plots), crops.sql (np_farming_plants), processing.sql (np_farming_stations), market.sql (np_farming_market, _market_history, _market_rep), contracts.sql (np_farming_contracts), animals.sql (np_farming_animals), bees.sql (np_farming_bees), coop.sql (np_farming_coops, np_farming_coop_members). Each file is split into blocks marked -- migration: <id>; at start np_farming applies every block of every enabled module once.

Building the UI ​

Build the NUI once before the first start, and again after any change under web/ (web/dist is not in the repository):

sh
cd web && npm install && npm run build

This creates web/dist/index.html (every screen and the field HUD) and web/dist/phone.html (the np_phone Harvest app).

Check it works ​

  1. The console prints the bridges, one line per sibling, the weather source and the item status. npfarming_status prints it again.
  2. npfarming_give <your id> tomato_seed 10 and npfarming_give <your id> watering_can give you seeds and a can.
  3. Rent a plot (the blip near Grapeseed), use a seed to open the placement grid, plant, press G to water and H to inspect a plant.
  4. /harvest opens the Harvest app when np_phone runs.

Before you open it ​

What the test harness cannot see is the game itself. Check these once on your server:

  1. Coordinates: plots and their water points (Config.Plots.list), the free planting zone, stations (Config.Processing.locations), buyers (Config.Market.buyers), the contract board and locker, the machine shed, the farm supply store (Config.Compat.supply.locations), the truffle forest zones.
  2. Props: one vanilla prop per crop stage (Config.Crops[*].props), station props, pen and hive props. GTA has no vanilla scarecrow: Config.Threats.crows.scarecrow.model is a sign by default; use an addon model.
  3. Animations per tool type (Config.Harvest.anims) and of every station.
  4. Your jobs in Config.Jobs, and the duty flag your framework reports.
  5. Item pictures in your inventory's image folder for every item.
  6. The weather source npfarming_status names, and how seasons feel with Config.World.seasonDays.
  7. Balance: crop times, yields, prices, demand and rent are first values.

Troubleshooting ​

Symptom Fix
Items cannot be used on ox / qb Paste the generated lists; the definitions call np_farming.useItem
The start-up status names missing items Run npfarming_install <inventory> and paste or import the result again
A harvest says you need a tool The tool type of that crop has no item in your pockets and no weapon of its list in your hand or loadout. See Tools
Harvesting at night is refused Config.Harvest.night.needsLight: carry a flashlight (weapon) or switch it off
Plants never get rain No weather source answers, or the plot is a greenhouse (it stays dry). Check npfarming_status
Selling answers not_available Standalone has no economy
Theft alarms reach nobody Config.Jobs.police does not list your police job, or nobody is on duty