CallRemoteEvent: Difference between revisions
From Onset Developer Wiki
No edit summary |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
====Limitations==== | ====Limitations==== | ||
* Maximum name length of a remote event: | * Maximum name length of a remote event: 128 characters | ||
* Maximum arguments to pass: | * Maximum arguments to pass: 14 | ||
* Valid Lua argument types: Integer, Boolean, Number, String, Table | * Valid Lua argument types: Integer, Boolean, Number, String, Table | ||
* Maximum String argument length: | * Maximum String argument length: 65536 characters | ||
* Maximum Table argument dimensions: | * Maximum Table argument dimensions: 5 | ||
* 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) | ||
Line 45: | Line 45: | ||
* [[AddRemoteEvent]] | * [[AddRemoteEvent]] | ||
* [[CallRemoteEvent]] | * [[CallRemoteEvent]] | ||
* [[BroadcastRemoteEvent]] | |||
* [[AddCommand]] | * [[AddCommand]] | ||
* [[GetAllPackages]] | * [[GetAllPackages]] |
Latest revision as of 17:05, 30 December 2020
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: 14
- Valid Lua argument types: Integer, Boolean, Number, String, Table
- Maximum String argument length: 65536 characters
- Maximum Table argument dimensions: 5
- 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)