Skip to main content

AddEventHandler

Adds an event handler to the provided event.

Syntax​

AddEventHandler event_name callback

Arguments​

NameRequiredTypeDescription
event nameYesAn in-game event e.g. RoundStarted (found using command 'serhelp events')
callbackYesA name of a function defined above e.g. MyFunction

Details​

Runs the function when the event happens. Prefer the '!-- OnEvent' flag when you can. Event variables such as @evPlayer are added automatically, so do not list them as function arguments. Calling AddEventHandler again for the same function replaces its previous event handler.

On a running server​

Use serhelp AddEventHandler to inspect the reference generated by your installed SER version.