Skip to content

Building, tests & screenshots ​

Layout ​

fxmanifest.lua                 globs: shared/lib, config, locales, bridges, client/*, server/*
shared/lib/                    00 core (NpGolf global, bridge selection) · 01 locale · 02 geometry · 03 physics · 04 scoring
shared/config.lua, shared/config/*.lua   Config: main, course, clubs, balls, economy, formats, natives
shared/locales/{en,de}.lua
bridge/np_admin.lua            np_admin lib, vendored byte-identical
shared/np_admin_settings.lua   np_admin Resource settings
bridge/framework/{client,server}/   esx | qbx | qb | standalone   (esx first)
bridge/inventory/server/            np_inventory | ox | qb | esx | none   (np_inventory first)
server/NN_*.lua                server core · db · rpc · money (escrow) · bag + profiles · lobby · round · bets · odds ·
                               stats · caddie · rpcs · carts · phone · integrations · exports · commands · np_admin
client/NN_*.lua                state · rpc · nui · world · play (address, swing, putting) · flight · cams · green ·
                               caddie · np_menu · survey · exports
web/                           React 18 + Vite + TypeScript: index.html (HUD + screens), phone.html (Fairway)
design/                        Nimbus UI tokens and CSS, never edited
sql/np_golf.sql, sql/esx_items.sql
tests/                         plain-Lua harness: server and client suites

shared/lib/03_physics.lua and 04_scoring.lua are pure Lua without natives: the client runs the physics for the preview, the server runs the same code for the real shot, and the scoring (skins, match, Nassau, Stableford, WHS differentials) is the same on the server and in the tests.

Build ​

sh
cd web
npm ci
npm run build          # FiveM guard check + tsc --noEmit + vite build → web/dist/index.html, web/dist/phone.html
npm test               # vitest: silver-line guard, projection, formatting
npm run dev            # browser mock, http://localhost:5186
npm run screenshots    # headless Chrome → web/screenshots/*.png
lua scripts/export-config.lua > src/dev/config.json   # after changing the course or clubs config

npm run build first runs scripts/check-fivem-guard.mjs: in FiveM a blurred surface renders as a black box over the game, so the HTML sets html.nb-fivem before the first paint and the CSS turns backdrop-filter off under it. The guard fails the build when that rule or the code that sets the class is missing.

Browser mock ​

npm run dev (or the --mode mock build) runs the UI without FiveM, with a fake Lua backend and a drawn course scene. URL parameters pick a screen:

Parameter Values
screen tee, putt, result, walk, spectate, scorecard, clubhouse, clubhouse-empty, bets, bets-player, bag, caddie
locale de
material liquid

The phone app runs at phone.html with tab (tee, live, odds, me) and shot=1.

npm run screenshots builds the UI and the mock, serves the mock with vite preview on port 4326 and renders every screen at 1920 × 1080 and the phone tabs at 520 × 920 into web/screenshots/. SCALE=3 renders at 3× for checks of the glass edges; a name filter renders one shot (npm run screenshots -- putt). The screenshots on these pages come from there.

Tests ​

sh
bash tests/run.sh             # luac -p on every Lua file, then the server and client suites (plain Lua 5.4)
VERBOSE=1 bash tests/run.sh   # with resource log lines and stubbed natives

The harness fakes oxmysql, the frameworks, the inventories and the siblings. The server suite covers the course data (tees and pins inside the course, GTA pars and yardage), lies and client hints, the meter and the ball physics (carry, shapes, wind, lie, sway, putting, lip-outs), the survey plane fit, handicap strokes and the WHS index, scoring (skins, match play, Stableford, leaderboards), escrow (every dollar kept, offline payouts), the tee sheet and checkout, shot validation, spectator and prop bets, a full round played out to an empty escrow, the events, disconnects, responsible play limits, np_admin, the Fairway app, np_inventory, an ESX bridge smoke test and a check that no ACE is used. The client suite covers the NUI handshake and RPC whitelist, addressing the ball, cycling clubs, the 3-click swing, putting, backing off and the settle step.

Not verifiable without a running server ​

  • The GOLF_TRAIL_* natives are undocumented, so the native preview trail is opt-in (Config.Native.trail.native).
  • Stance offsets, the impact moment in the swing clips, the hole-preview camera origin and the cart barn position are tuned values; adjust them in shared/config/natives.lua and shared/config.lua if a swing looks off.
  • SET_MINIMAP_GOLF_COURSE expects a centred, zoomed radar; np_golf doesn't lock the minimap (Config.Native.minimap = false turns the drawing off).
  • Fairway corridors and green radii are approximations; green slopes are configured until /golfsurvey measures them.

Conventions ​

  • One global NpGolf (plus Config, Locales). Lua 5.4; every file parses with plain lua 5.4.
  • Results are plain tables with ok; errors carry a code.
  • Money is whole dollars, timestamps unix seconds, world positions metres; displayed distances are yards.
  • No ACE anywhere: every staff check is npAdmin.can(src, node).