CallRemoteEvent: Difference between revisions

From Onset Developer Wiki
No edit summary
No edit summary
Line 4: Line 4:


====Limitations====
====Limitations====
* Maximum name length of a remote event: 64 characters
* Maximum name length of a remote event: 128 characters
* Maximum arguments to pass: 10
* Maximum arguments to pass: 10
* Valid Lua argument types: Integer, Boolean, Number, String, Table
* Valid Lua argument types: Integer, Boolean, Number, String, Table
* Maximum String argument length: 1024 characters  
* Maximum String argument length: 8192 characters  
* Maximum Table argument dimensions: 2
* Maximum Table argument dimensions: 3
* Maximum Table keys: 1000 entries
* Maximum Table keys: 1000 entries
* Valid Table argument keys: Number, Integer, String (32 characters)
* Valid Table argument keys: Number, Integer, String (32 characters)

Revision as of 20:08, 8 March 2020

CallRemoteEvent

Type: Function
Context: Server & Client
Introduced: v1.0

Description

Calls a remote event on the remote machine. The server can call remote events for any connected player. Players (clients) can only call remote events on the server. Events are guaranteed to execute in the order sent. Keep in mind that it takes time to reach the remote machine as it's send over the network.
Remote events are independent of packages meaning you can call remote events across different packages.

Limitations

  • Maximum name length of a remote event: 128 characters
  • Maximum arguments to pass: 10
  • Valid Lua argument types: Integer, Boolean, Number, String, Table
  • Maximum String argument length: 8192 characters
  • Maximum Table argument dimensions: 3
  • Maximum Table keys: 1000 entries
  • Valid Table argument keys: Number, Integer, String (32 characters)
  • Valid Table argument values: Integer, Boolean, Number, String, Table

Syntax

CallRemoteEvent(player, EventName [, LuaArgs...])
Client Syntax
CallRemoteEvent(EventName [, LuaArgs...])

Parameters

  • player
    The player identifier to call a remote event.
  • 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)
	CallRemoteEvent(player, "ServerCallsMe", 1337, 3.1415, "hello client!")
end
AddEvent("OnPlayerJoin", OnPlayerJoin)

Script on the client:

function ServerCallsMe(arg1, arg2, arg3)
	AddPlayerChat("Server called ServerCallsMe("..arg1..", "..arg2..", "..arg3..")")
end
AddRemoteEvent("ServerCallsMe", ServerCallsMe)

See also