🤠 Wild Country Libs
Client API

Wagons

Vehicle spawn/delete/repair helpers and wheel-bone lookup. Framework-agnostic — pure native wrappers.

SpawnWagon(modelName, x, y, z, heading, opts) → number|nilclient

Spawns a wagon model at the given coordinates. Returns the vehicle handle, or nil on failure.

ParamTypeDescription
modelNamestring | numberModel name or hash.
x, y, znumberSpawn coordinates.
headingnumberSpawn heading in degrees.
opts.brokenbooleanDamage, freeze, and break the front-left wheel.
opts.isMissionbooleanMark as a mission entity.
opts.frozenbooleanFreeze position without applying damage.
opts.timeoutMsnumberModel load timeout in ms. Defaults to 10000.
DeleteWagon(wagon)client

Safely deletes a wagon entity.

ParamTypeDescription
wagonnumberVehicle entity handle.
RepairWagon(wagon)client

Fixes damage, restores all health values, and makes the wagon driveable.

ParamTypeDescription
wagonnumberVehicle entity handle.
FreezeWagon(wagon, freeze)client

Freezes or unfreezes the wagon's position.

ParamTypeDescription
wagonnumberVehicle entity handle.
freezebooleanTrue to freeze, false to unfreeze.
GetWheelPos(wagon, which) → vector3|nilclient

Returns the world position of the specified wheel bone. Falls back to calculated offsets if the model has no matching bone.

ParamTypeDescription
wagonnumberVehicle entity handle.
whichstring'lf' (front-left), 'lr' (rear-left), 'rr' (rear-right), 'rf' (front-right).
example
-- Spawn a broken-down wagon as a scene prop
local wagon = wc:SpawnWagon('WAGON02X', 1234.0, -567.0, 89.0, 45.0, {
  broken    = true,
  isMission = true,
})

-- Later, reveal it's been fixed
wc:RepairWagon(wagon)

-- Clean up
wc:DeleteWagon(wagon)

Real Wild County example — stagecoach breakdown encounter

wc_stagecoach/client/main.lua
local wagon = wc:SpawnWagon('WAGON03X', pos.x, pos.y, pos.z, heading, { broken = true })
local wheelPos = wc:GetWheelPos(wagon, 'lf') -- where the player kneels to fix it

-- after the repair minigame:
wc:RepairWagon(wagon)
wc:FreezeWagon(wagon, false)

Common mistakes

Troubleshooting