Installation
- Copy the
draggy
resource folder into your server’sresources
directory. - Ensure qb-core or ox_inventory dependencies are installed.
- Configure
Config.lua
to match your inventory setup. - Add to
server.cfg
:ensure draggy
- Restart your server to load the resource.
Configuration
Edit Config.lua
to set:
useItem
– Require special item to start drag race.inventory
– Set to"ox"
or"qb"
.itemName
– The item required to activate dragging.updateInterval
– Milliseconds between UI updates.
Commands
/draggy
– Toggle drag race UI and start benchmark loop.
Permission Check
canUseDragFeature(source, cb)
– Checks inventory forConfig.itemName
before enabling drag race.
Benchmark Features
- Speed benchmarks: 0->60, 0->100, 0->120 MPH.
- Distance benchmarks: 1/8, 1/4, 1/2, and 1 mile times.
- Top speed tracking.
- One-time power & torque snapshot via
GetVehicleWheelPower
.
NUI Usage
The script communicates with the UI through these actions:
action: "open"
– Show UI with initial stats.action: "update"
– Send live speed, times, and performance data.action: "status"
– Display status text (e.g., "READY!" or "Race Completed!").action: "close"
– Hide UI.
Examples
-- Start drag race defaultCommand("draggy") -- Toggles UI and begins benchmark loop
-- Reset benchmarks resetBenchmarks()
Tips & Best Practices
- Adjust
updateInterval
to balance performance and responsiveness. - Wrap critical calls (
GetVehicleWheelPower
) inpcall()
to prevent errors. - Ensure proper cleanup by handling UI close when players exit the vehicle.
- Customize UI position and scale in the open action payload.