Skip to content

Command Responses

Josh Bowden edited this page Jul 26, 2026 · 1 revision

A button can display a value your server sends back: radio volume, fuel level, on-duty count, anything a resource can print.

Requires v2.1.0 or later, and a change to the command on the server. Without that change nothing comes back.


Turning It On

It is off by default. Open Advanced Settings and tick Enable command responses. A Show response checkbox then appears under every command field, along with the rest of the settings below.

Tick Show response only for commands you have updated on the server. Any other command receives an unexpected extra argument, explained below.


How It Works

With Show response ticked, FXCommands appends a short token to the command before sending it.

radio_voldown @fxid:ab12cd34

It then watches the game console for a line containing that same token, strips the token out, and puts whatever is left on the button.

The token is what keeps buttons from crossing wires. Press three buttons at once and each one only reacts to the line carrying its own token.

If no matching line arrives before the timeout, the button is left as it was.


The Server Side

Your command has to pull the token off the end of its arguments and print it back alongside the value, on the same line.

RegisterCommand('radio_voldown', function(source, args)
    local sdToken = nil
    if args[#args] and args[#args]:match("^@fxid:") then
        sdToken = table.remove(args)
    end

    -- Regular command logic here

    if sdToken then
        print(("%s %s"):format(sdToken, "60.0"))
    end
end)

Two things matter:

  • Remove the token from the arguments before your command uses them, or it will be treated as a real argument.
  • Print it on the same line as the value. Position on the line does not matter, the token is stripped wherever it appears, but nothing else should be on that line.

Warning: Ticking Show response on a command that does not do this sends @fxid:... as an extra argument. Depending on the command that is either ignored or an error.


Displaying the Value

Control Where it appears
Key The button title
Dial The touch strip above the dial

Response Label (keys)

Controls the formatting of the title. Use {value} for the response, and press Enter for a line break.

Volume

{value}

Leave it blank and the title is replaced with the raw response.

Percentage bar (dials)

On a dial, a response formatted as a percentage also draws a progress bar. Print a trailing %.

print(("%s %d%%"):format(sdToken, volume))

Without the % the value is shown on its own.


Get Value

Runs whenever the button appears: plugin start, profile load, switching to that page. It exists so the button shows the current value instead of a stale one from last session.

It captures a response the same way, so its command needs the same token handling.

Also run after commands without "Show response" re-reads the value after any command on that button. Useful when the command that changes a value is not the one that reports it.


Response Timeout

How long to wait for the console line, in Advanced Settings. Defaults to 1500ms.

The ceiling is 5000ms because the FiveM client drops the connection after five seconds of inactivity.


See Also

Clone this wiki locally