AddRemoteEvent: Difference between revisions
From Onset Developer Wiki
No edit summary |
No edit summary |
||
Line 8: | Line 8: | ||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|RemoteEventName|The remote event name.}} | {{FuncParam|RemoteEventName|The remote event name.}} | ||
{{FuncParam|LuaFunction|The lua function you want to call.}} | {{FuncParam|LuaFunction|The lua function you want to call. Values you return from this function won't be transmitted to the originating CallRemoteEvent.}} | ||
{{FuncReturnValue|This function has no specific return value.}} | {{FuncReturnValue|This function has no specific return value.}} |
Revision as of 13:30, 27 February 2020
Description
The remote event to call from either server to client or vice versa.
Syntax
AddRemoteEvent(RemoteEventName, LuaFunction)
Client Syntax
AddRemoteEvent(RemoteEventName, LuaFunction)
Parameters
- RemoteEventName
The remote event name. - LuaFunction
The lua function you want to call. Values you return from this function won't be transmitted to the originating CallRemoteEvent.
Return Value
- This function has no specific return value.
Example
-- This example calls the remote event from the server side to the client side
-- Client side
AddRemoteEvent("SetWeather", function(weatherid)
SetWeather(weatherid)
end)
-- Server side
AddCommand("we", function(playerid, weatherid)
CallRemoteEvent(playerid, "SetWeather", weatherid)
end)
-- This example calls the remote event from the client side to the server side
-- Client side
AddEvent("OnKeyPress", function(key)
if key == 'R' then
CallRemoteEvent("OnClientRadio")
end
end)
-- Server side
AddRemoteEvent("OnClientRadio", function(playerid)
AddPlayerChat(playerid, "Client activated radio")
end)