mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 02:01:31 +00:00
Merge pull request #1342 from Kenshiin13/add(TriggerClientEventForPlayers)
feat(es_extended/server/functions): add ESX.TriggerClientEvent
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user