umsg filter

How can I filter who a usermessage goes to?

I never quite understood it.

[lua]umsg.Start(“umsg_name”, ply)
umsg.End()[/lua]

Not how to start a usermessage, how to decide who it is sent to.

This

If you noticed, the second argument of umsg.Start indicates which entity receives the umsg.

If you want to send it to all players, don’t give a filter argument.



umsg.Start( "SomeMessage" )
...
umsg.End( )


Will send to all players



umsg.Start( "SomeMessage", pl )
...
umsg.End( )


Will send it to a specific player.

If you want to send it to some players, use a recipient filter for the filter argument.

**[G.RecipientFilter

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=G.RecipientFilter)**
**[R.CRecipientFilter

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=CRecipientFilter)**



local rf

rf = RecipientFilter( )
rf:AddPVS( tr.HitPos )

umsg.Start( "SomeMessage", rf )
...
umsg.End( )


:smith:

[lua]
local filter = RecipientFilter()
filter:RemoveAllPlayers()
filter:AddPlayer(ply)
[/lua]
Edit: damn, you beat me to it, kogitsune :expressionless:

Hmm.

Thats what I though with the function parameters.

Seems I had another slit of code that was interfering with it.