RegisterMessage

Syntax

native MessageHook:RegisterMessage(const msg_id, const callback[], post = 0);

Usage

Parameter Description
msg_id
The ID of the message to register the callback for.
callback
The name of the callback function.
post
Whether the callback should be invoked before or after processing the message. (optional)

Description

Registers a callback function to be called when a game message with the specified ID is received.

Note

  • The callback arguments have:
    msg_id - Message id
    msg_dest - Destination type (see MSG_* constants in messages_const.inc)
    msg_entity - Entity receiving the message
  • You can modify the message content using SetMessageData native before the original function is invoked.
    Also can reading the message content using GetMessageData native.
    
    In the callback function, use the return values from Hookchain return types, such as HC_CONTINUE, HC_SUPERCEDE, etc.
    to control the flow of message processing.

Return

Returns a handle to the registered message hook.