Garry's Mod Wiki

gameevent.Listen

  gameevent.Listen( string eventName )

Description

Adds a game event listener, creating a new hook using the hook library, which can be listened to via hook.Add with the given eventName as event.

All gameevents are called in the Menu State, but if you want to use them you need to use some DLL(like this one) or you need to create your own.

Arguments

1 string eventName
The event to listen to. List of valid events (with examples) can be found here.

Example

Example usage of this function. Listens to the player_disconnect game event and prints a message every time it is ran.

gameevent.Listen( "player_disconnect" ) hook.Add( "player_disconnect", "my_player_disconnect_hook", function( ... ) print( "player_disconnect", ... ) end)