Players Filter
Manage and synchronize a list of players matching pre-defined conditions
Code: guthscp.players_filter
Extends: guthscp.filter
Realm: Shared
Description
Players filters are containers useful for caching a list of players with pre-determined conditions.
Similarly to filters, they must be instantiated on both client and server sides. As filters are automatically synchronized after a modification, only the server needs to manage their content. The client should only receive data from the server and should not alters the content by itself.
By itself, a filter won't do anything unless you told him so. Therefore, you should either use FILTER:listen_<...>
methods or manually hook into game events and use FILTER:add
and FILTER:remove
methods.
Methods
void
listen_disconnect()
Makes the filter to automatically clean-up disconnected players.
void
listen_weapon_users( string weapon_class )
Makes the filter to automatically add players who are using a specific weapon class and to remove those who are not.
Example
A common use case is to gather a list of players using a certain SCP weapon for later use. Code from guthscp173:
guthscp173.filter =
if SERVER then
guthscp173.filter:listen_disconnect()
guthscp173.filter:listen_weapon_users( "guthscp_173" ) -- being SCP-173 just mean a player having the weapon
( "guthscp173:unfreeze", function( ply )
ply:SetNWBool( "guthscp173:looked", false )
end )
end
Last updated