BroadcastRemoteEvent

From Onset Developer Wiki
Revision as of 17:12, 30 December 2020 by BlueMountains (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
BroadcastRemoteEvent

Type: Function
Context: Server
Introduced: v1.4.0

Description

This function has the same functionality as CallRemoteEvent. The difference is that this function can call a remote event on all connected players.

See CallRemoteEvent for detailed explanations and limitations.

Syntax

BroadcastRemoteEvent(EventName [, LuaArgs...])

Parameters

  • EventName
    The name of the remote event as a string which was explicit defined by AddRemoteEvent.
  • UserArgs (optional)
    Arguments to pass to the remote event.

Return Value

  • Returns true on success or false on an error.

Example

Script on the server:

function OnPlayerJoin(player)
	-- Calls the remote event "ServerCallsMe" on all connected players.
	BroadcastRemoteEvent("PlayerJoin", player)
end
AddEvent("OnPlayerJoin", OnPlayerJoin)

Script on the client:

function PlayerJoin(player)
	AddPlayerChat("Server called PlayerJoin("..player..")")
end
AddRemoteEvent("PlayerJoin", PlayerJoin)

See also