RegisterNetEvent
Marks the event safe for network use. Aka, allows you to trigger the eventName event on the client, from a server side script. If you do not provide a callback function use AddEventHandler to listen for the event after registering it.
Syntax
RegisterNetEvent(string eventName, function callback)
Required arguments
- eventName: A string representing the event name to register.
Optional arguments
- callback: The function to run when the event is called.
Examples
RegisterNetEvent('eventName', function(...)
print('Event fired')
end)
or
RegisterNetEvent('eventName')
AddEventHandler('eventName', function(...)
print('Event fired')
end)
Last modified July 6, 2021: Add optional arguments to RegisterNetEvent. (42ae506)