WM_VEHICLECONTROLL / VEHICLE LUA
Build your own wm_vehiclecontroll file!
Build the moving parts and controls for your vehicle. Recovery trucks, fire engines, rotators, cranes and other custom rigs can all use this system. The examples below show where each feature goes in a vehicle Lua file.
Files and registration
Give each vehicle its own Lua file in the vehicles folder. The script loads files in that folder when the resource starts. The example below uses one moving boom; replace it with the parts on your own model. If several versions share the same equipment, see Vehicle variants.
RegisterRecoveryVehicleConfig('my_rig', {
model = 'my_rig',
name = 'My Rig',
speed = 1.0,
control = {
radius = 20.0,
menu = { enabled = false }
},
props = {
{
name = 'boom',
prop = 'my_rig_boom',
attach = 'vehicle',
offSet = { 0.0, -2.0, 0.5 },
rotation = { 0.0, 0.0, 0.0 },
rotation_min = { 0.0, 0.0, 0.0 },
rotation_max = { 15.0, 0.0, 0.0 },
offset_min = { 0.0, 0.0, 0.0 },
offset_max = { 0.0, 0.0, 0.0 },
controlls = {
{ button = 173, movementType = 'rotate', axis = 1, movementAmount = 0.1 },
{ button = 172, movementType = 'rotate', axis = 1, movementAmount = -0.1 }
}
}
}
})Change my_rig to your vehicle's spawn name, then replace the boom model and positions with your own. Restart the resource to load your changes.
Vehicle settings
Start with the vehicle model and the parts you want to move. The settings below go inside its vehicle definition, next to props. Attachment and operator options have their own sections further down this page.
| Field | Purpose |
|---|---|
model | The vehicle's spawn name. This is how the script recognises it. |
name | The label shown for the vehicle. |
props | The bed, lift, boom and other moving parts. Give each part its own name. |
speed | How quickly the moving parts respond. Start at 1.0 and adjust from there. |
rootAttach | Changes where the whole setup sits on the vehicle. Normally you can leave it out. |
control | Where the operator stands and how the control menu works. |
travelDirectAttach / spectatorDirectAttach | Keep carried vehicles attached while driving and for nearby players watching. Both are on by default. |
Props and positions
Think of props as the vehicle's working parts: bed, boom, ladder, lift, hook and so on. Each part needs a name, a model and something to attach to. Attach the first part to 'vehicle'; attach later parts to the name of another part if they should move together. Positions use three numbers in X, Y, Z order.
| Field | Purpose |
|---|---|
name, prop, attach | Internal part name, prop model and parent. All three are required for a normal prop. |
offSet, rotation | Starting local position and rotation. |
offset_min, offset_max | Travel limits for move controls. |
rotation_min, rotation_max | Travel limits for rotate controls. |
controlls | List of button-driven actions. The spelling is intentional. |
visible, keepCollision | Initial visibility and collision behaviour. visible defaults to true. |
bone | Optional vehicle bone for a root prop; vehicleBone and boneIndex are also accepted. |
virtual | A non-visual prop node; a prop model is not required. |
winchAttachPoints | Named points on a real prop for the standalone winch. |
dynamicpropattach | Opt this prop into automatic object attachment. |
variantPropPrefix = false | Keep a shared accessory's model name unchanged across variants. |
Controls and supported types
Each part can respond to one or more buttons. Add those actions to its controlls list. The button number chooses the FiveM input; movementType says what the button does. The script supports these ten actions. Placing a person on a part uses a separate setting called pedplace.
| movementType | Use | Section |
|---|---|---|
move | Translate a prop along X, Y or Z. | Movement |
rotate | Rotate a prop around X, Y or Z. | Movement |
toggle | Show or hide a prop. | Movement |
rope | Extend or retract a rig rope/hoist. | Rope |
waterparticle | Emit a particle effect from a prop. | Water |
attachvehicle | Fix a whole vehicle to a prop. | Vehicle |
attachvehiclebywheel | Couple by the front wheel bones. | Wheels |
attachvehiclebybody | Couple by two body points. | Body |
attachtrailer | Connect a trailer at its hitch. | Trailer |
attachcontainer | Attach a container when the roof state permits it. | Container |
Button Conditions
Button Conditions decide when a button may be used. Add them to a button inside a prop's controlls. They work with Toggle, Attach Vehicle by Wheel, Attach Vehicle by Body and Attach Trailer. For Toggle, the conditions are checked when showing a hidden part; the same button can still hide it again.
| Setting | What it does |
|---|---|
requiresVisibleProp | The named part must be visible. |
requiresHiddenProp | The named part must be hidden. |
requiresHiddenProps | Every part in the list must be hidden. |
requiresNoWheelAttachment | No vehicle may be held by the wheel or body pickup. |
requiresNoTrailerAttachment | No trailer may be attached to the rig. |
visible = false | Starts this prop hidden. Add it to the prop itself, outside controlls. |
Use the exact names of other parts from your props list. This example shows every condition on one Toggle button; keep only the ones your vehicle needs.
visible = false,
controlls = {
{
button = 201,
movementType = 'toggle',
requiresVisibleProp = 'cover',
requiresHiddenProp = 'boom',
requiresHiddenProps = { 'left_foot', 'right_foot' },
requiresNoWheelAttachment = true,
requiresNoTrailerAttachment = true
}
},Move / Rotate / Toggle
Move slides a prop, Rotate turns it, and Toggle shows or hides it. Give each movement direction its own button. The axis chooses X, Y or Z; a positive or negative amount chooses which way it moves. Set the prop's minimum and maximum positions so it stops at the right point.
controlls = {
{ button = 173, movementType = 'rotate', axis = 1, movementAmount = 0.1 },
{ button = 172, movementType = 'rotate', axis = 1, movementAmount = -0.1 },
{ button = 174, movementType = 'move', axis = 2, movementAmount = 0.01 },
{ button = 175, movementType = 'move', axis = 2, movementAmount = -0.01 },
{ button = 201, movementType = 'toggle' }
}Set visible to false on a prop that should start hidden. Add only the buttons that make sense for that part of your rig.
Rope
Rope connects a prop, such as a boom, to a second prop, such as a hook block. One button lets rope out and another reels it in. Give both buttons the same rope name and set attachto to the prop at the other end.
controlls = {
{
button = 173,
movementType = 'rope',
name = 'mainHoist',
attachto = 'hookblock',
direction = 1,
speed = 0.5,
initialLength = 0.5,
maxLength = 30.0,
points = {
{ from = { 0.0, 1.0, 0.0 }, to = { 0.0, 0.0, 0.0 } }
}
},
{
button = 172,
movementType = 'rope',
name = 'mainHoist',
attachto = 'hookblock',
direction = -1,
speed = 0.5,
initialLength = 0.5,
maxLength = 30.0
}
},Water Particle
Water Particle makes a nozzle or other prop spray a chosen effect when its button is pressed. Set asset and name to the effect you want, then move the spray to the right place with offSet and rotation. The example can be switched on and cycles through three spray sizes.
controlls = {
{
button = 157,
movementType = 'waterparticle',
asset = 'core',
name = 'water_cannon_jet',
toggle = true,
scales = { 1.0, 1.5, 2.0 },
offSet = { 0.0, 0.0, 0.0 },
rotation = { 0.0, 0.0, 0.0 }
}
},attachvehicleAttach Vehicle
Attach Vehicle fixes a nearby vehicle to the chosen prop of your rig, such as a flatbed. The offSet and rotation in the button action decide where the vehicle sits. Press the button again to release it.
Where it goes: inside the controlls of the prop that carries the vehicle, such as your bed. Put controlls next to that prop's offSet and rotation.
controlls = {
{
button = 47,
movementType = 'attachvehicle',
offSet = { 0.0, 0.0, 0.35 },
rotation = { 0.0, 0.0, 0.0 },
radius = 8.0
}
},attachvehiclebywheelAttach Vehicle by Wheel
Attach Vehicle by Wheel holds a vehicle by its two front wheels on your wheel-lift prop. Put one pickup point under the left wheel and one under the right. The button couples or releases the vehicle.
Where it goes: inside the controlls of your wheel-lift prop.
controlls = {
{
button = 29,
movementType = 'attachvehiclebywheel',
axis = 1,
rotationFollowAxis = 3,
points = {
{ name = 'left', offSet = { -0.83, -0.65, 0.26 }, bone = 'wheel_lf', radius = 5.0 },
{ name = 'right', offSet = { 0.83, -0.65, 0.26 }, bone = 'wheel_rf', radius = 5.0 }
}
}
},attachvehiclebybodyAttach Vehicle by Body
Attach Vehicle by Body holds a vehicle at two points on its body. Use it for a cradle or rotator that lifts the vehicle without gripping the wheels. Put left and right pickup points on the carrying prop, then use the button to couple or release the vehicle.
Where it goes: inside the controlls of the cradle or rotator prop that touches the recovered vehicle.
controlls = {
{
button = 29,
movementType = 'attachvehiclebybody',
axis = 1,
rotationFollowAxis = 3,
points = {
{ name = 'left', offSet = { -0.68, -0.42, 0.0 }, radius = 5.0 },
{ name = 'right', offSet = { 0.68, -0.42, 0.0 }, radius = 5.0 }
}
}
},attachtrailerAttach Trailer
Attach Trailer lets you place an attach_female hitch point at an offset on one of your rig's props. Press the chosen button to attach a trailer to that prop. The trailer connects through its attach_male bone.
Where it goes: add this button to the prop that holds the trailer hitch. The three position numbers in the example place the hitch on that prop: left or right, forward or back, and up or down.
controlls = {
{
button = 29,
movementType = 'attachtrailer',
bone = 'attach_male',
point = { offSet = { 0.0, -0.21, 0.19 }, radius = 5.0 }
}
},The radius sets how close the trailer needs to be to connect; use a value above 0 and no higher than 5.
attachcontainerAttach Container
Attach Container fixes a nearby container to a prop at the position set by offSet and rotation. Its button works only when the vehicle's animConvRoof is at state 2. Press the button again to release the container.
Where it goes: inside the controlls of the prop that holds the container. In this example, that prop is the bed.
controlls = {
{
button = 47,
movementType = 'attachcontainer',
attachcontainer = 'container_mount',
anchorProp = 'bed',
offSet = { 0.0, 0.0, 0.0 },
rotation = { 0.0, 0.0, 0.0 },
radius = 8.0
}
},dynamicAttachDynamic Vehicle Attach
Dynamic Vehicle Attach secures another vehicle to any rig prop listed in allowedProps. You can list several props. Set vehicle to true to allow attachment to the rig's vehicle body as well, or false to use only the listed props.
Where it goes: next to props in the vehicle Lua file. This feature has no controlls action.
dynamicAttach = {
allowedProps = { 'bed' },
vehicle = true,
automatic = true
},Add more prop names after bed, separated by commas. With automatic set to true, a vehicle can be secured after it comes to rest on an allowed surface. Set it to false when the operator should attach it manually.
dynamicpropattachDynamic Prop Attach
Dynamic Prop Attach secures loose objects on a rig prop, such as equipment on a bed. When the vehicle travels, those objects stay with the prop. Add this setting to the prop that carries them; there is no button action for it.
dynamicpropattach = {
radius = 3.0,
surfaceTolerance = 0.35,
maxHeight = 2.5,
maxObjects = 8
},Radius sets the area around the prop. Surface tolerance and maximum height decide which objects count as cargo; maxObjects limits how many are secured. For the standard values, set dynamicpropattach to true on the prop. This works with networked objects.
disableoutsidecontrollDisable Outside Control
Disable Outside Control keeps operation inside the cab. Set it to true to block the outside control mode and let the driver select rig parts from their seat. Add this line beside props in the vehicle Lua.
disableoutsidecontroll = true,cancontrollselectedpropsfrominsideControl Selected Props from Inside
Control Selected Props from Inside lets the driver operate chosen parts from the seat while outside operation remains available. Set the vehicle option to true, then add allowseatmoving to each prop the driver may select. Unmarked props stay out of the inside selection.
cancontrollselectedpropsfrominside = true,allowseatmoving = true,The vehicle option goes beside props; allowseatmoving goes inside each permitted prop. That prop still needs its usual movement buttons.
raisetrailerlegRaise Trailer Leg
Raise Trailer Leg gives the operator a button to raise the support legs on an attached trailer. Set the number to the FiveM button you want. If no trailer is connected, the operator gets a message. Add this beside props in the vehicle Lua.
raisetrailerleg = 47,indicatorsonmovingIndicators on Moving
Indicators on Moving switches on the rig's hazard lights while someone operates its equipment. When operation ends, the previous indicator state returns. Set it to true beside props in the vehicle Lua.
indicatorsonmoving = true,animroofblockAnim Roof Block
Anim Roof Block stops the operator from toggling the animated roof while they control the rig. Set it to true beside props in the vehicle Lua. Return to Default can still close the roof if that feature is enabled.
animroofblock = true,closeanimroofatreturnlastClose Anim Roof at Return
Close Anim Roof at Return closes the animated roof after Return to Default has put the rig's moving parts away. Set it to true beside props in the vehicle Lua.
closeanimroofatreturnlast = true,pedplacePed Place
Ped Place gives a player a position on a prop, such as a cage or basket. Add it inside that prop's controlls and choose the command they use to get on or off. One command can do both; you can also give entering and leaving separate commands.
controlls = {
{
pedplace = true,
command = 'cage',
pedplacecontroll = true,
offSet = { -0.2, 1.0, 0.95 },
rotation = { 0.0, 0.0, 0.0 }
}
},For a stretcher, setplayerinit = true lets the operator choose a nearby player to place on it. This mode needs pedplacecontroll = false. To play an animation while that player is on the prop, set animation = true. thisdict names the animation set; thisname names the animation within it. Both must be filled in when animation is enabled.
controlls = {
{
pedplace = true,
command = 'stretcher',
pedplacecontroll = false,
setplayerinit = true,
offSet = { 0.0, 0.0, 1.255 },
rotation = { 0.0, 0.0, -90.0 },
animation = true,
thisdict = 'anim@gangops@morgue@table@',
thisname = 'body_search'
}
},Add pedPlaceHideGuard = true to the prop if it should stay visible while someone is on it.
controlOperator Control
Operator Control sets where a person can operate the rig and what happens when they start. Radius decides how close they must be; attach chooses the vehicle body or a moving prop as their operating point. You can open a menu and play a remote-control animation. Add this table beside props in the vehicle Lua.
Set secondaryremotecontrol = true to offer a second handheld remote option. The player can start control near the vehicle without standing at the usual operator point. The radius still decides how close they need to be.
control = {
radius = 20.0,
attach = 'vehicle',
secondaryremotecontrol = true,
menu = {
enabled = true,
resourceName = 'my_vehicle_menu',
automaticOpen = true,
key = 311,
ownsFocus = true,
returnControl = 56
},
animation = {
enabled = true,
idle = { dict = 'wm_wv_pedanim', name = 'idle', flag = 49 },
prop = {
enabled = true,
model = 'wm_wv_remotecontroll',
attachToPed = {
boneIndex = 57005,
offSet = { 0.19, 0.05, -0.22 },
rotation = { -60.0, -114.0, 12.0 }
}
}
}
},winchAttachPointsWinch Attach Points
Winch Attach Points adds places where a winch can connect on a rig prop. The player chooses one of these fixed points, then chooses what to pull. Add the points to the prop; offSet places each one on the model and radius sets how close the player must stand.
winchAttachPoints = {
{ name = 'left', offSet = { -1.15, 0.0, -0.56 }, radius = 1.5 },
{ name = 'right', offSet = { 1.15, 0.0, -0.56 }, radius = 1.5 }
},Vehicle Variants
Vehicle Variants lets several versions of the same rig share one prop layout, such as ELS and non-ELS models. In each row, the first name is the vehicle's spawn name. The second is the prefix used by that version's prop models. The third is the menu resource for that version. Add these rows to extravehiclenames in the vehicle Lua.
The third name is optional. Leave it out to use the menu resource from control.menu, or use an empty string to disable the menu for one variant.
local baseConfig = {
model = 'my_rig_els',
extravehiclenames = {
{ 'my_rig_els', 'wm_my_rig_els', 'my_rig_els_menu' },
{ 'my_rig_non', 'wm_my_rig_non', 'my_rig_non_menu' }
},
control = { radius = 20.0, menu = { enabled = true, resourceName = 'my_rig_els_menu' } },
props = {
{
name = 'bed',
prop = 'wm_my_rig_els_bed',
attach = 'vehicle',
offSet = { 0.0, -2.0, 0.5 },
rotation = { 0.0, 0.0, 0.0 },
rotation_min = { 0.0, 0.0, 0.0 },
rotation_max = { 0.0, 0.0, 0.0 },
offset_min = { 0.0, 0.0, 0.0 },
offset_max = { 0.0, 0.0, 0.0 },
controlls = {}
}
}
}
RegisterRecoveryVehicleVariants(baseConfig)The first prefix must match the base prop names in your file. An accessory can use the same model on every version.