ClientEvent

This is a library for sending events to the client in synchronous and asynchronous ways optionally waiting for a response.

Example

client.lua

Listen clients from the server.

-- Gets the client listener api.
---@type ClientListenerApi
client_listener_api = exports.nss_libs:getClientListenerApi(GetCurrentResourceName())

-- Register a listener for the event "test" and return the result.
---@param _source number The identifier of the client that fired the event.
---@param times number Example argument.
client_listener_api:addListener('test', function(_source, times)

    local result = {}

    for _ = 1, times do
        table.insert(result, 'Hello from client')
    end

    print('Client Result', table.unpack(result))

    return result
end)

server.lua

Fires events to the client.

Last updated

Was this helpful?