CRecipientFilter.AddPlayer

From GMod Wiki

Jump to: navigation, search
Function
Syntax CRecipientFilter:AddPlayer( Player player )
Description:
Adds a single player to the recipient filter.
Returns: nil
In Object: CRecipientFilter
Realm: NewerServer.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=CRecipientFilter.AddPlayer]CRecipientFilter.AddPlayer [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionAdds then removes Player 1, Adds then removes all players, Adds then removes all player that can potentially be seen from Player 2
Used onNewerServer.png
Code
 
PL1 = player.GetByID(1)
PL2 = player.GetByID(2)
RP = RecipientFilter()
RP:AddPlayer( PL1 )
RP:RemovePlayer( PL1 )
RP:AddAllPlayers()
RP:RemoveAllPlayers()
RP:AddPVS( PL2 )
RP:RemovePVS( PL2 )
 
OutputN/A


DescriptionGives you 2 new console commands, one adds a specified PlayerID from the "status" command, the other sends a usermessage to all of the added players.
Used onNewerServer.png
Code
local RF = RecipientFilter() // Create a filter which we will fill with players
concommand.Add("RF_AddPlayer",function(ply, cmd, args)
	if not args[1] then return end // If he didn't give us a argument
	local ID = tonumber(args[1]) // Make his argument into a number
	RF:AddPlayer(Player(ID)) // Add the player to the filter
end)
concommand.Add("RF_SendMessage",function(ply, cmd, args)
	umsg.Start("LuaExample",RF) // Send a usermessage to all of the added players.
		umsg.String("Blah")
	umsg.End()
end)
OutputN/A

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox