Events

av_laptop:terminal

Triggers terminal actions from the client side. Similar to a terminal export, with the added capability of being triggered remotely by server events.

params:

server.lua
-- Triggered from server side
local playerMoney = exports['av_laptop']:getMoney(source, "bank") or 0
local actions = {
    {
        type = "text",
        input = "You current bank funds are: $"..playerMoney,
        delay = 600
    },
}
TriggerClientEvent("av_laptop:terminal", source, actions)

Example

server.lua
local test_command = {
    command = "cosmo", -- command to use in terminal
    show = true, -- Set to true if you want the command to be visible in the terminal command list
    allowed = function(playerId, laptopSerial)
        return true
    end,
    onSuccess = function(playerId, laptopSerial)
        local playerMoney = exports['av_laptop']:getMoney(playerId, "cosmo") or 0
        local actions = {
            {
                type = "text",
                input = "Your current Cosmo balance is: "..playerMoney,
                delay = 600
            },
        }
        TriggerClientEvent("av_laptop:terminal", playerId, actions)
        return true
    end,
    canProcess = function(playerId, laptopSerial, args)
        return true
    end,
    actions = {
        {type = "progressbar", input = "Fetching player Cosmo...", delay = 3000},
    },
}

CreateThread(function()
    while not GetResourceState('av_laptop') == 'started' do
        Wait(100)
    end
    local added, msg = exports['av_laptop']:addCommand(test_command)
    print("Adding terminal command:", added, msg)
end)

Last updated