Documentation

FiveM Script Docs

General server guides and documentation for all SWR Entertainment FiveM scripts.

Installing a FiveM Resource

General Guide

Follow these steps to install any FiveM resource, including SWR scripts, on your server.

Steps

  1. 1Download the resource .zip from your Tebex receipt, the release page, or wherever the script was provided.
  2. 2Extract the archive. Confirm the extracted folder contains a fxmanifest.lua or __resource.lua at its root. That is your resource folder.
  3. 3Move the resource folder into your server's resources directory. You can organise scripts in sub-folders (e.g. resources/[swr]).
  4. 4Open server.cfg and add an ensure line for the resource. The name must match the folder name exactly.
  5. 5Save server.cfg and restart your server (or run ensure <resource-name> in the server console to hot-reload without a full restart).

Example server.cfg entry

ensure swr_cve_v2
Tip: If the resource fails to start, check the server console for errors. Missing dependencies listed in fxmanifest.lua are the most common cause.

cfx-swr-vending - Documentation

Vending Machine Script

Prop-triggered, NUI-based vending machines for FiveM. Players walk up to a machine, press E, and get a branded menu to purchase items. Includes custom audio, post-purchase animations, multiplayer proximity sound, and deep per-machine configurability from a single config.lua.

Requirements

  • FiveM server running artifact 2802 or newer (cerulean fx_version).
  • Lua 5.4 enabled (lua54 'yes' is set in the manifest).
  • An emote resource that registers /e <name> (compatible with rpemotes-reborn and dpemotes).
  • Framework: ESX (es_extended), QBCore (qb-core), or Standalone (no dependency).

Installation

  1. 1Drop the cfx-swr-vending folder into your server's resources directory.
  2. 2Add to server.cfg: ensure cfx-swr-vending.
  3. 3Open config.lua and set framework and money account.
  4. 4ESX / QBCore only: ensure item names in each machine's items table exist in your inventory.
  5. 5Restart the resource or reboot the server.
Config.Framework = 'esx'      -- or 'qb' or 'standalone'
Config.MoneyAccount = 'cash'  -- or 'bank'
No SQL. No imports. No additional dependencies beyond your framework and an emote resource.

Standalone / Custom Economy

When Config.Framework = 'standalone', the server fires a net event instead of touching any economy:

TriggerEvent('swr-vending:standaloneGive', source, itemName, price)

Listen to this event in your own resource to charge money and give the item however your server handles it.

Configuration Reference

All settings live in config.lua. The file is excluded from CFX asset escrow so it remains editable after purchase.

General

KeyDefaultDescription
Config.InteractDistance1.6Metres from a machine before prompt appears.
Config.InteractKey38GTA control index used to open menu (38 = E).
Config.Use3DPrompttrueShow floating 3D text when in range.
Config.PlayAnimationtruePlay post-purchase animations.
Config.PlayGrabAnimationtruePlay reach-and-grab animation before emote.
Config.EmoteCommand'e'Emote chat command prefix.
Config.Framework'standalone''esx', 'qb', or 'standalone'.
Config.MoneyAccount'cash''cash' or 'bank' for ESX/QBCore.
Config.PurchaseCooldown0Minimum ms between purchases per player; 0 disables.

Audio

KeyDefaultDescription
Config.AudioRadius20.0Radius for nearby players to hear purchase sound.
Config.PurchaseVolume0.5Volume (0.0 to 1.0) for purchasing player.
Config.NearbyMaxVolume0.5Max nearby volume with linear fade to 0 at edge.

Audio plays through NUI (browser Audio API). Place custom mp3 files in html/sound/ and register each file in fxmanifest.lua under files {}.

Prompt / 3D Text

KeyDefaultDescription
Config.PromptOffsetZ0.85Height above prop Z origin for prompt text.
Config.PromptKeyHint'[E]'Blue hint prefix; set empty string to hide.
Config.PromptFont4GTA font index.
Config.PromptScale0.34Prompt text scale.
Config.PromptTextColor{255,255,255,215}Text RGBA color.
Config.PromptBoxColor{0,0,0,150}Background box RGBA color; alpha 0 disables box.

Grab Animation (global defaults)

KeyDefaultDescription
Config.GrabAnimDict'mini@sprunk'Animation dictionary.
Config.GrabAnimClip'plyr_buy_drink_pt1'Clip name.
Config.GrabAnimDuration3500Milliseconds to hold the clip.
Config.GrabAnimBlendIn8.0TaskPlayAnim blend-in rate.
Config.GrabAnimBlendOut-8.0TaskPlayAnim blend-out rate.
Config.GrabAnimStopBlend3.0StopAnimTask blend-out speed.
Config.GrabFaceDuration800Duration for TaskTurnPedToFaceEntity.
Config.GrabFaceWait700Wait time while turn completes.

Scan / Detection Intervals

KeyDefaultDescription
Config.ScanInterval800ms between scans when no machine is near.
Config.NearbyInterval250ms between scans when machine is nearby.

Machine Configuration

Each entry in Config.Machines represents a brand. Add, remove, or rename brands freely. The resource auto-builds prop to brand lookup at startup.

Required fields

FieldDescription
propsList of model hashes (`prop_name`) used to identify this machine in world.
itemsList of { label, item, price } products shown in menu.

Appearance

FieldDescription
headerImage filename from html/images used as brand banner.
accentHex color string for machine theme in NUI menu.
subtitleText shown in menu header and world prompt.

Prompt overrides (optional)

FieldDescription
promptTextOverride 3D prompt text independent of subtitle.
promptHeightOverride Config.PromptOffsetZ for this machine only.
interactDistanceOverride Config.InteractDistance for this machine only.

Audio (optional)

FieldDescription
soundmp3 filename in html/sound; nil or omitted means no sound.

Choice screen (optional)

FieldDefaultDescription
showChoicetrueShows Drink it / Hold it screen after item pick.
defaultAction'hold'Used when showChoice is false: 'drink' or 'hold'.

Animations (optional)

FieldDescription
emotes{ drink = 'emoteName', hold = 'emoteName' }. Omitted keys do not fire emote.
emoteDelayDelay in ms after grab animation ends before emote runs.
grabAnimPer-machine override for dict, clip, duration, blendIn, blendOut, stopBlend.

Broadcast (optional)

FieldDescription
broadcastString or string table sent to global chat. %s becomes buyer name.

Full machine example

['mybrand'] = {
    props = { `prop_vend_soda_01` },
    items = {
        { label = 'My Drink', item = 'mydrink', price = 5 },
        { label = 'Diet Drink', item = 'dietdrink', price = 4 },
    },
    header = 'mybrand.png',
    accent = '#ff6600',
    subtitle = 'The best drink in Los Santos',
    promptText = 'Grab a drink',
    promptHeight = 1.0,
    interactDistance = 2.0,
    sound = 'vendingmachine.mp3',
    showChoice = true,
    defaultAction = 'drink',
    emotes = { drink = 'soda2', hold = 'soda' },
    emoteDelay = 0,
    grabAnim = {
        dict = 'mini@sprunk',
        clip = 'plyr_buy_drink_pt1',
        duration = 3500,
        blendIn = 8.0,
        blendOut = -8.0,
        stopBlend = 3.0,
    },
    broadcast = {
        '%s is thirsty!',
        '%s grabbed a drink.',
    },
},

Adding a new machine brand

  1. 1Create a brand image and place it in html/images/.
  2. 2Add a new entry to Config.Machines in config.lua.
  3. 3For custom sound, add mp3 to html/sound/ and register it in fxmanifest.lua under files {}.
  4. 4Ensure item names exist in your inventory system.
  5. 5Run ensure cfx-swr-vending in server console.

Adding custom audio

  1. 1Place mp3 files in html/sound/.
  2. 2Register each file explicitly in fxmanifest.lua.
  3. 3Set sound = 'mysound.mp3' on the machine entry in config.lua.
files {
    'html/sound/vendingmachine.mp3',
    'html/sound/coffee.mp3',
    'html/sound/mysound.mp3',
}

Multiplayer behavior: purchaser hears at Config.PurchaseVolume. Nearby players inside Config.AudioRadius hear with linear falloff.

Notifications

The script uses GTA native feed notifications. To replace with your framework notify, edit swr-vending:notify at the bottom of client.lua.

RegisterNetEvent('swr-vending:notify', function(message, kind)
    -- Replace this block with your framework notify export/event
    BeginTextCommandThefeedPost('STRING')
    AddTextComponentSubstringPlayerName(message)
end)

Troubleshooting

IssueChecklist
Menu does not openConfirm prop hash is listed in machine props, range is within interact distance, and config has no startup errors.
No sound playsVerify mp3 exists in html/sound and is explicitly listed in fxmanifest files, then inspect NUI DevTools for file/audio errors.
Nearby players do not hear soundIncrease audio radius and ensure nearby players have interacted at least once to prime NUI audio context.
Emote does not playStart emote resource before this resource, verify EmoteCommand and exact emote names, and account for emoteDelay.
Items not given or money not deductedValidate framework mode and item names against your inventory definitions; inspect framework errors in server console.
Cooldown not workingPurchase cooldown is milliseconds, memory-only, and resets on resource restart.
Grab animation looks wrongSet per-machine grabAnim overrides for non-soda props.
config.lua encrypted after escrowEnsure escrow_ignore includes config.lua in fxmanifest and re-upload through Tebex.

Net events reference

EventSideArgumentsDescription
swr-vending:purchaseServer receivebrand, itemIndexClient purchase confirmation.
swr-vending:purchaseSuccessClient receive-Fired on successful transaction to trigger animations.
swr-vending:notifyClient receivemessage, kindDisplays success or error notifications.
swr-vending:nearbySoundClient receivesoundFile, volumeInstructs nearby clients to play purchase audio.
swr-vending:standaloneGiveServer receivesource, item, priceStandalone handoff for external economy/inventory.

Clearing FiveM Cache

General Guide

Clearing your FiveM cache resolves texture glitches, loading failures, and outdated script errors that persist after a server update.

Steps

  1. 1Fully close FiveM. Open Task Manager and confirm no FiveM processes are still running.
  2. 2Press Win + R, paste the path below, and press Enter.
  3. 3Inside that folder, open FiveM.app then open the cache subfolder.
  4. 4Delete all subfolders and files inside cache. You can leave the empty cache folder itself in place.
  5. 5Relaunch FiveM. The cache will rebuild automatically on startup. This may take a few extra minutes on first load.

Cache folder path

%localappdata%\FiveM\FiveM.app\cache
Note: You do not need to delete priv or any folder outside of cache. Doing so may require you to re-link your FiveM account.

Updating Server Artifacts

General Guide

FiveM server artifacts are the core server binaries. Keeping them up to date ensures compatibility with new game builds and security patches.

Steps

  1. 1Visit the artifacts page for your OS and download the latest recommended build.
  2. 2Stop your FiveM server completely before making any file changes.
  3. 3Back up your current artifact files by copying them to a separate folder. This lets you roll back if something breaks.
  4. 4Extract the new artifact files into your server root directory, overwriting the existing binaries.
  5. 5Start your server and verify the updated version number appears in the server console output.
Windows:  https://runtime.fivem.net/artifacts/fivem/build_server_windows/master/
Linux:    https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/
Before updating: Review the Cfx.re changelog for the selected build. Occasionally artifact updates require config or resource changes to avoid breaking your server.

SWR Fire Notify

Fire & EMS Station Tone-Out + Bay Door System

Fire and EMS station tone-out and bay door system for Night ERS. When a player accepts a fire or EMS callout, tones go out at the nearest station that serves that department and that station's bay doors open automatically. Tones are fully positional 3D: they play at the station's coords with distance fade and stereo pan, so any player near the station hears them too.

  • Fire callouts → fire tone at the nearest station with services.fire = true
  • EMS callouts → EMS tone at the nearest station with services.ems = true
  • A call needing both departments tones both (each at its own nearest station)
  • Doors at every toned station swing open and stay open until commanded closed
No dependencies: audio is rendered by this resource's own NUI (Web Audio API), doors use GTA's native door system.

How It Works

Night ERS fires a server event when a callout is accepted: ErsIntegration::OnAcceptedCalloutOffer. This resource listens to that event, no edits to ERS are needed. On accept: match the callout to fire/EMS → find the nearest station serving each → every client near that station plays the tone positionally → the station's bay doors open for everyone.

Framework Modes

ModeTriggerCommand Restrictions
'ers'Night ERS callout accept (default)None
'esx'Night ERS callout acceptDoor/test commands limited to Config.AllowedJobs (ESX jobs)
'qbcore'Night ERS callout acceptSame, via QBCore jobs
'standalone'Any SmartFires callout, no ERS neededNone

In standalone mode the fire tone plays and doors open at the station nearest to the fire itself the moment a SmartFires callout spawns. Set Config.SmartFiresAnyFire = true to also activate for every fire SmartFires creates; the station cooldown is then the only spam limiter.

Requirements

  • Night ERS (for ers / esx / qbcore modes) or SmartFires (standalone mode). That's it. No xsound or other audio resource needed.

Installation

  1. 1Copy the folder into your resources directory (e.g. resources/[local]/cfx-swr-fire-notify).
  2. 2Put your tone files in html/sounds/: .ogg recommended (or .mp3). Ships expecting fd-tone.ogg (fire), ems-tone.ogg (EMS) and test-tone.ogg (test command).
  3. 3Open config.lua: set your stations in Config.Stations (vector4 coords with services = { fire = ?, ems = ? }), confirm tone filenames in Config.Departments.*.tones, and tune volume / distance settings.
  4. 4Register your bay doors in-game using /registerdoors (see Station Bay Doors below).
  5. 5Add to server.cfg:
    ensure night_ers
    ensure cfx-swr-fire-notify

Commands

CommandWhat it does
/teststationtones3D test tone at your nearest station (pre-shift readiness check).
/openbay [bay number]Open one bay door at your nearest station.
/openallstationdoorsOpen every door at your nearest station.
/closeallstationdoorsClose every door at your nearest station.
/registerdoorsToggle door-registration mode (see Station Bay Doors below).
/stoptonesInstantly silence every tone on your client.
/tonesdiagDump audio engine state including each tone's live volume/pan.

Command names are configurable in config.lua.

Test Tone (Pre-Shift Readiness)

Run /teststationtones at your station. It plays Config.TestTone positionally at your nearest station, exactly like a real callout tone, so any crew near the station hears it too. Walk toward/away and turn around to hear the distance fade and stereo pan, then tune with Config.AudibleDistance, Config.FullVolumeDistance and Config.FalloffExponent.

All tones are positional, so you only hear them within Config.AudibleDistance of the station. If a tone seems silent, you are too far away.

Trigger the same test from your own resource:

-- Server side (you have the player's server id):
exports['cfx-swr-fire-notify']:TestStationTones(playerId)

-- Client side (from a readiness UI/button):
TriggerServerEvent('swr-fire-notify:testStationTones')

Station Bay Doors

Bay doors auto-open at the toned station on callout accept (Config.OpenDoorsOnAccept) and stay open until commanded closed. States sync to every player including late joiners. Doors are held closed and locked by default.

  1. 1Run /registerdoors to toggle registration mode.
  2. 2Stand near the station, aim at the bay door, and fire an empty weapon (0 ammo, loaded weapons are refused).
  3. 3A ready-to-paste line prints to the F8 console with the station auto-filled:
    { station = 2, door = 0, model = -1420538493, coords = vector3(1189.42, -1481.30, 35.01) }, -- SET door = bay number!
  4. 4Change door = 0 to the bay number you want (that's the [bay number] for /openbay), paste the line into Config.Doors, restart the resource.
  5. 5If a door opens the wrong direction, add ratio = -1.0 to its line.
Keep station bay doors exclusive to this resource. If another doorlock script also manages the same door, they will fight over its state.

Audio File Format

Export from Audacity: File > Export > Export as OGG (recommended) or Export as MP3. Lowercase filenames, no spaces, into html/sounds/, then list them in the relevant department's tones array. Multiple files = random pick each tone-out. .ogg, .mp3 and .wav all decode through the Web Audio API. .ogg is the best size/quality trade-off.

Key Config Options

OptionMeaning
Config.Framework'ers' / 'esx' / 'qbcore' / 'standalone' (see Framework Modes above).
Config.AllowedJobsESX/QBCore: jobs allowed to use door and test commands.
Config.SmartFiresAnyFirestandalone: activate for every fire, not just SmartFires callouts.
Config.Stationsvector4 stations + services = { fire, ems } flags.
Config.Departments.<dept>.tonesTone filename(s) in html/sounds/. Multiple = random each time.
Config.Departments.<dept>.calloutIdsCallout IDs for that department (pre-filled from Night ERS).
Config.VolumeVolume at the station (0.0–1.0).
Config.AudibleDistanceHow far (m) the tone carries before fading to silence.
Config.FullVolumeDistanceWithin this many metres of the station = full volume; fade starts beyond it.
Config.FalloffExponentFade curve steepness. 1 = linear, higher = quicker drop-off.
Config.StationCooldownSeconds before the same station+dept can tone again.
Config.OpenDoorsOnAcceptAuto-open the toned station's bay doors on callout accept.
Config.DoorsBay door list: paste lines from /registerdoors.
Config.TestToneSound file used by /teststationtones.
Config.OnlyRequiredFlagtrue = match departments only by ERS's required flags, ignore id lists.
Config.UseCalloutLocationtrue = nearest station to the incident instead of the player.
Config.DebugVerbose logging (server console + F8) for setup/troubleshooting.

First-Time Setup Tip

Set Config.Debug = true, accept a fire/EMS callout in-game, and watch the server console. It prints the exact calloutData your ERS sends, which department(s) matched, and which station was chosen. Turn it off once setup is confirmed.

Troubleshooting

  • No sound at all? Confirm filenames in Config.Departments.*.tones exactly match files in html/sounds/. A missing file prints a tone "..." failed line in F8. /tonesdiag should report running.
  • Tone seems silent? You are outside Config.AudibleDistance; all tones are positional.
  • Wrong callouts toning? Adjust department calloutIds lists, or set Config.OnlyRequiredFlag = true to trust only ERS's flags.
  • Station tones for wrong department? Fix its services flags.
  • Fade feels too gradual or abrupt? Raise/lower Config.FalloffExponent and adjust Config.FullVolumeDistance.
  • Door won't budge / moves wrong way? Re-register it, or add ratio = -1.0 to its entry in Config.Doors.
  • /registerdoors says "No door object hit"? Aim at the center of the door panel (not the frame/wall) within ~40m and fire again.

Escrow

fxmanifest.lua is Cfx.re asset-escrow ready: config.lua, html/sounds/** and documentation stay open/editable after upload; scripts get encrypted when processed by the Cfx.re portal.

CVE V2

Coming Soon

Commercial Vehicle Enforcement V2

CVE V2 is the next generation of our Commercial Vehicle Enforcement script. It introduces enhanced weigh station mechanics, full DOT inspection workflows, a configurable violation and fine system, and deep framework integration, built for realistic LEO and DOT roleplay on any FiveM server.

In Development

Full documentation, configuration reference, and installation guide will be published here when CVE V2 releases. Join our Discord to be notified first.

AI Towing V2

Coming Soon

AI Towing V2

AI Towing V2 is a complete rebuild of our original AI Towing script. V2 features smarter NPC dispatch logic, multi-vehicle tow support, fully configurable tow zones and cooldowns, and native integration with popular FiveM frameworks like ESX and QBCore.

In Development

Full documentation, configuration reference, and installation guide will be published here when AI Towing V2 releases. Join our Discord to be notified first.

Can't find what you need? Ask in our community.

Join Discord