S&box Wiki

Revision Difference

EventSystem#529769

<title>Event System</title>⤶ ⤶ The event system is like the Hook system in Garry's Mod. It allows you to register functions on classes to receive a callback on certain global events.⤶ ⤶ ⤶ # Registering a callback⤶ ⤶ Adding an `[Event]` attribute will add it to the list to be called.⤶ ⤶ ```⤶ [Event( "server.tick" )]⤶ public void MyCallback()⤶ {⤶ // will get called every server tick⤶ }⤶ ```⤶ ⤶ ⤶ # Custom Events⤶ ⤶ You can call your own events.⤶ ⤶ ```⤶ Event.Run( "gameover" )⤶ ```⤶