usermessage.Hook

From GMod Wiki

Revision as of 03:48, 9 September 2011 by Acruid (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax usermessage.Hook( String message_name, Function message_hook, [...] )
Where is this used?
Description:
Allows you to receive custom User Messages
Returns: nil
Part of Library: usermessage
Realm: NewerClient.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Usermessage.Hook]Usermessage.Hook [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionHooks the usermessage "My Message"
Used onNewerClient.png
Code
function my_message_hook( um )
    Msg( um:ReadString() )
end
usermessage.Hook("my_message", my_message_hook)
OutputN/A


DescriptionPasses the SWEP table to the hook function, so that "self" can be used.
Used onNewerClient.png
Code
function SWEP.umsgHook( um, self )
 
-- changes the fire mode so HUD can update accordingly
self.FireMode = um:ReadShort()
 
end
usermessage.Hook( "swep.FireMode", SWEP.umsgHook, SWEP )
OutputN/A


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox