Exports

This page explains how to register and execute commands and actions from external scripts using the terminal's built-in exports.

addExternal(name,callback)

Use this export to register a custom callback. It triggers whenever the terminal processes an action with a matching callback value.

Parameters

  • name:string Action name, should match the field callback from a server side action.

  • callback: function(data) Callback to perform

Return

  • success:boolean true will allow the command to execute the following actions, false will stop everything and print the failure action.

addSuccess(command, callback)

Use this export to register a onSuccess callback to trigger when a command is completed successfully.

Parameters

  • command:string Must be an existing command.

  • callback:function(data) Callback to perform

terminal(action)

Triggers an array of actions within the terminal, adhering to the format specified in Terminal

local actions = {
    {
        type = "text",
        input = "No vehicle found nearby.",
        style = "error",
        delay = 0
    }
}
exports['av_laptop']:terminal(actions)

Keyfob Example

This example script registers the keyfob command to execute a sequence of actions, demonstrating how to:

  • Trigger 3 custom client-side callbacks (demo:validate, demo:getClosest, and demo:processKeys).

  • Use the userInput action type to pause the sequence and capture the vehicle's SSID.

  • Reward the player with the vehicle keys once the entire action sequence is successfully completed.

Last updated