-
Notifications
You must be signed in to change notification settings - Fork 3
Custom Events
Konijima edited this page Jul 11, 2022
·
4 revisions
Add the Custom Events to create into your config file.
ClientEvents = {
"MyCustomClientEvent",
"OnPlayerJumpCompleted",
"OnPlayerPunchGround",
},
ServerEvents = {
"MyCustomServerEvent",
"OnPlayerDied",
},All custom events are internally prefixed with your ModName to prevent conflict between mods.
Add a callback to a Custom Event to be executed when the event is triggered.
local function myCustomEventCallback(arg1, ...)
Client.Log("My custom client event has been triggered!");
end
Client.AddEvent("OnMyCustomClientEvent", myCustomEventCallback);local function myCustomEventCallback(arg1, arg2, arg3)
Server.Log("My custom server event has been triggered!");
end
Server.AddEvent("OnMyCustomServerEvent", myCustomEventCallback);Remove a callback from a Custom Event to stop it from being executed when the event is triggered.
Client.RemoveEvent("OnMyCustomClientEvent", myCustomEventCallback);Server.RemoveEvent("OnMyCustomServerEvent", myCustomEventCallback);Trigger a Custom Event and pass any parameters that you need.
Client.TriggerEvent("OnMyCustomClientEvent", "param1", "param2", "param3");Server.TriggerEvent("OnMyCustomServerEvent", "param1", "param2", "param3", "param4", "param5", "param6", "param7", "param8");The game engine limits us to a maximum of 8 parameters.