Legacy Scripts

legacy-towing

Overview

What legacy-towing does and how it's put together.

legacy-towing

Bayview towing — dynamic trailers, flatbeds, ramps, hitching and winching, all configured in-game.

What it does

legacy-towing replaces menu-driven towing with physical, in-world systems:

  • Carrying — park a vehicle on a rig's deck (flatbed, trailer, boat trailer, etc.) and it auto-attaches once you step out, provided it's slow enough (Config.MaxAttachSpeed) and there's room (client/carry.lua).
  • Slots vs dynamic decks — a rig is either mode = 'slots'/'fixed' (authored cradle positions, snapped into place, no overlap test needed) or a free-form dynamic deck (any position on an authored polygon, with a live footprint/overlap test so cargo can't be driven through each other once attached entities stop colliding).
  • Hitching — client/hitch.lua auto-detects a tow ball / trailer coupling by bone (attach_male/attach_female) or, failing that, by GetVehicleType() == 'trailer' plus model dimensions, and shows a hold-to-hitch prompt when in range and in the driver's seat.
  • Winching — client/winch.lua is a from-scratch rope system (not a menu): take a hook prop off the rig, walk it to a vehicle, latch on, walk back, and hold a key to reel it in along a physically simulated rope built with AddRope.
  • Ramps — flatbeds can lower/raise a physical ramp prop, a vehicle extra, or a door, all driven off a server-owned statebag so every client sees the same state.
  • Admin authoring — all per-vehicle rig data (deck outlines, slots, ramp geometry, winch anchor points) is authored in-game through a React/Tailwind NUI, opened with /towingconfig (configurable), and persisted server-side to data/rigs.json. This file's config only holds resource-wide behaviour, not per-vehicle rig definitions.

Architecture

  • Server is authoritative for who is carrying what, who holds a winch claim, and whether ramps are down. It owns data/rigs.json and pushes the resolved config to clients on join via legacy-towing:server:requestConfig / legacy-towing:client:config.
  • Statebags carry ambient state (legacyTowCarrier, legacyTowWinch, legacyTowRamps) because attachment, ropes, vehicle extras and doors do not reliably replicate between clients on their own — every client independently applies the same statebag value to reach the same visual result.
  • The web/ folder is a separate Vite/React/Tailwind build for the admin NUI; it must be built (npm run build) to web/dist before the resource is deployed.

See Configuration for every static config key, Integration for exports/events other resources can use, and Troubleshooting for known gotchas.

Overview · legacy-towing · Legacy Scripts