Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(es_extended/server/functions): add ESX.TriggerClientEvent #1342

Merged
merged 2 commits into from
Apr 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions [core]/es_extended/server/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ function ESX.Trace(msg)
end
end

--- Triggers an event for one or more clients.
---@param eventName string The name of the event to trigger.
---@param playerIds table|number If a number, represents a single player ID. If a table, represents an array of player IDs.
---@param ... any Additional arguments to pass to the event handler.
function ESX.TriggerClientEvent(eventName, playerIds, ...)
if type(playerIds) == "number" then
TriggerClientEvent(eventName, playerIds, ...)
return
end

local payload = msgpack.pack_args(...)
local payloadLength = #payload

for i = 1, #playerIds do
TriggerClientEventInternal(eventName, playerIds[i], payload, payloadLength)
end
end

function ESX.RegisterCommand(name, group, cb, allowConsole, suggestion)
if type(name) == "table" then
for _, v in ipairs(name) do
Expand Down
Loading