Shared side of the server transfer areas of the SrcdsProxy plugin: the proxy_transfer
area type. A transfer area keeps the name of a server of the proxy network in its backend
field and a number of seconds in its delay field; a player who stays in it for that long
is moved to that server.
Summary
Hooks
Methods
Proxy table exists.[U:1:123]).Proxy.transfer: whitespace, semicolons and double quotes are removed.Proxy.chat_commands setting, so that the chat forms such as !server reach the Flux commands, replaces its srcdsproxy_* console commands with ones that run the Flux commands, and answers its admin check with the moderate permission.SrcdsProxy:find_targets into a readable list for a notification: the names of the players on this server and the IDs of everyone else.SrcdsProxy.max_transfer_delay.SrcdsProxy:quote.Hooks
Implements hook AddAreaToolModes
Adds the Server Transfer Area mode to the Area Tool. When the list has such a mode already, as it does after a code refresh, the mode takes its place and any other one is removed, so that the indices of the other modes stay the same.
Parameters
- mode_list Map the Area.tool_modes table; modes are added with mode_list:Add
Implements hook FLHUDPaint
Draws the countdown of the transfer area the local player is in, if one runs: the server
they are about to be moved to and the seconds that are left. Once it has ended the server
the player is being moved to is shown, for at most moving_time seconds.
Parameters
- cur_time Number CurTime() of the frame
- scrw Number screen width
Hands the addon's commands over to Flux once every addon and the gamemode have loaded.
Implements hook LazyTick
Updates the transfer states of the players eight times a second: cancels the countdowns of the players who have left their area, ends those whose time has come, and starts the transfer areas that players are in and have not been dealt with in.
Hands the addon's commands over to Flux again after a Lua refresh.
Implements hook PlayerDisconnected
Forgets the transfer state of a player who leaves the server.
Parameters
- actor Player
Methods
Checks whether the srcdsproxy backend addon is installed, that is whether its
Proxy table exists.
Returns
- Boolean
SrcdsProxy:ban(actor, name, target, duration, reason)
server plugins/srcdsproxy/plugin/sv_plugin.lua:337Has the proxy ban targets from the whole network on behalf of the caller, who has to be a
proxy admin. Players on this server are found by SrcdsProxy:find_targets and have to
pass the caller's immunity check. A duration that SrcdsProxy:is_duration accepts (such
as 30m, 2h, 7d or 1w) is passed on as one; anything else is the first word of the
reason. The proxy kicks whoever the ban covers and answers in the caller's console.
Parameters
- actor Player the caller
- name String the verb: 'ban' to ban SteamIDs, addresses or subnets, 'banip' to ban the addresses of players
- target String player name, target selector, SteamID,
#id, address or subnet - duration String optional, defaults to
nilban duration, or the first word of the reason - reason String optional, defaults to
nilthe rest of the reason
Returns
- List<Map> the entries of SrcdsProxy:find_targets that have been banned, or nil if nothing has been sent, after the caller has been notified
SrcdsProxy:cancel_transfer_countdown(actor, state)
server plugins/srcdsproxy/plugin/lib/sv_transfer_areas.lua:103Stops the countdown of a player, if one runs, and takes it off their HUD.
Parameters
- actor Player
- state Map the transfer state of the player
Checks whether the srcdsproxy backend addon is installed and tells the caller that it is missing if it is not.
Parameters
- actor Player the caller, an invalid entity for the server console
Returns
- Boolean
Checks whether the caller is connected through the proxy, which the proxy's commands need, since the proxy only takes them from a player's session. The caller is told when the addon is missing or they are not connected through the proxy; the server console never is.
Parameters
- actor Player the caller, an invalid entity for the server console
Returns
- Boolean
SrcdsProxy:enter_transfer_area(actor, area)
server plugins/srcdsproxy/plugin/lib/sv_transfer_areas.lua:119Deals with a player who has entered a transfer area. Nothing happens when the addon is missing, the player is not connected through the proxy or is dead, the area names no server, the player has been dealt with in this area since they entered it, or another countdown of theirs runs. A player who is on the area's server already is left alone, one who may not enter it is told that it is whitelist-only, and everyone else gets a countdown of the area's delay, which they are told about.
Parameters
- actor Player the player who has entered the area
- area Map the transfer area
SrcdsProxy:enter_transfer_areas_at(actor, areas)
server plugins/srcdsproxy/plugin/lib/sv_transfer_areas.lua:251Starts the transfer area a player is in, when no countdown of theirs runs: the first one they have not been dealt with in since they entered it.
Parameters
- actor Player
- areas List<Map> the transfer areas
Finds the player on this server whom the proxy knows by a SteamID64 or by a SteamID3
([U:1:123]).
Parameters
- argument String
Returns
- Player the player, or nil if the argument is neither or nobody here has it
SrcdsProxy:find_targets(actor, argument, check_immunity)
server plugins/srcdsproxy/plugin/sv_plugin.lua:224Finds whom a player argument of a proxy command targets, as IDs the proxy understands.
An argument that has the form of an IP address or a subnet goes to the proxy as it is, and
so does one that starts with # (a session ID from GList). Otherwise the players on this
server are looked up by their SteamID64 or SteamID3 and with Flux.Command:str_to_player,
which matches their names exactly and makes the target selectors work for them, and each
of them stands for the SteamID64 the proxy knows them by. A name that several players here
have targets nobody, and the caller is told to use a SteamID. Those who are not connected
through the proxy, or have no SteamID there, are left out and the caller is told about each
of them. When nobody on this server matches, the argument goes to the proxy as it is, which
finds players on every server of the network by name, SteamID or #id.
With check_immunity the caller has to pass the immunity check against every player found
on this server, unless the command is run from the server console; if any of them is
immune, nobody is targeted. Since a #id may belong to a player on this server whose
immunity cannot be checked, players are not allowed to use one then.
Parameters
- actor Player the caller, an invalid entity for the server console
- argument String player name, target selector, SteamID,
#id, address or subnet - check_immunity Boolean optional, defaults to
falsecheck the immunity of the players on this server
Returns
- List<Map> entries with the
id(String) to give to the proxy and theplayer(Player) on this server it stands for, if any; nil if nobody is left, after the caller has been notified
SrcdsProxy:finish_transfer_countdown(actor, state, area)
server plugins/srcdsproxy/plugin/lib/sv_transfer_areas.lua:196Ends the countdown of a player: moves them if they are alive, which the caller has checked them to be in the area too. A move that has been sent stays on the HUD while the player is in the area; otherwise the countdown is taken off it.
Parameters
- actor Player
- state Map the transfer state of the player
- area Map the transfer area of the countdown
Checks whether a text has the form of an IPv4 or IPv6 address, or of a subnet written as an address followed by a slash and a prefix length.
SrcdsProxy:is_address('203.0.113.0/24') -- true
SrcdsProxy:is_address('2001:db8::1') -- true
SrcdsProxy:is_address('STEAM_0:1:123') -- false
Parameters
- text Any
Returns
- Boolean
SrcdsProxy:is_current_backend(actor, backend)
server plugins/srcdsproxy/plugin/lib/sv_transfer_areas.lua:73Checks whether a player is on the named server of the network already. Server names are compared without regard to case, as the proxy does.
Parameters
- actor Player a player who is connected through the proxy
- backend String server name
Returns
- Boolean
Checks whether a text is a ban duration the way the proxy reads one: a number of
minutes, amounts with the units s, m, h, d and w written together (1h30m), or
0, perm, permanent, forever or never for a permanent ban. Case is ignored.
SrcdsProxy:is_duration('1h30m') -- true
SrcdsProxy:is_duration('rude') -- false
Parameters
- text Any
Returns
- Boolean
Checks whether a player may enter a server of the network on their own request: it is not whitelist-only, or they are on its whitelist or a proxy admin. The proxy still decides when the player is sent, and it does not know here whether the server exists or is up.
Parameters
- actor Player
- backend String server name
Returns
- Boolean
SrcdsProxy:new_transfer_area_id(backend)
shared plugins/srcdsproxy/plugin/lib/sh_transfer_areas.lua:41Finds an ID for a new transfer area that moves players to a server: the server's name made into an ID, with the first number that no area has yet. Both realms have the same areas, so they find the same ID.
Parameters
- backend String server name, as returned by
SrcdsProxy:server_name
Returns
- String
Turns a text into one argument of a proxy command: in double quotes, so that names with spaces stay together, and without the line breaks, semicolons and double quotes that the command parser would act on.
SrcdsProxy:quote('John "JD" Doe;')
-- '"John JD Doe"'
Parameters
- text Any text of the argument, converted with tostring
Returns
- String
Checks whether the caller is a proxy admin: listed in the proxy's admins.toml and verified by Steam. The proxy itself only takes whitelist and ban commands from them; this check tells everybody else so right away. The caller is notified when the check fails.
Parameters
- actor Player the caller, an invalid entity for the server console
Returns
- Boolean
Sends one or more commands to the proxy on behalf of the caller, who has to be connected through the proxy. The proxy answers in the caller's console, which the caller is told once all of the commands have been sent.
SrcdsProxy:run(actor, 'glist')
Parameters
- actor Player the caller, an invalid entity for the server console
- verbs String/List<String> proxy commands, as built by
SrcdsProxy:verb
Returns
- Boolean whether the commands have been sent
Turns what a player typed as the name of a server of the network into one word that is
safe to pass to Proxy.transfer: whitespace, semicolons and double quotes are removed.
Parameters
- text String server name as typed
Returns
- String the server name, or nil if nothing is left of it
Hands the srcdsproxy addon's commands over to Flux: turns off the addon's chat commands
through its Proxy.chat_commands setting, so that the chat forms such as !server
reach the Flux commands, replaces its srcdsproxy_* console commands with ones that run
the Flux commands, and answers its admin check with the moderate permission. Without
the addon nothing is changed, and a warning is printed the first time.
Turns the entries of SrcdsProxy:find_targets into a readable list for a notification:
the names of the players on this server and the IDs of everyone else.
Parameters
- entries List<Map> entries of SrcdsProxy:find_targets
Returns
- String
Turns a value into the delay of a transfer area: a number of seconds from 0 to
SrcdsProxy.max_transfer_delay.
Parameters
- value Any delay as a number or a text
Returns
- Number the delay,
SrcdsProxy.default_transfer_delayif the value is no number
SrcdsProxy:transfer_from_area(actor, area)
server plugins/srcdsproxy/plugin/lib/sv_transfer_areas.lua:160Moves a player whose countdown has ended to the server of the transfer area, unless the area names no server any more, the player is not connected through the proxy or is on that server already, may not enter it (they are told it is whitelist-only), or a plugin vetoes the move.
Parameters
- actor Player the player whose countdown has ended
- area Map the transfer area
Returns
- Boolean whether the player has been sent to the proxy
SrcdsProxy:update_transfer_state(actor, state, stored, cur_time)
server plugins/srcdsproxy/plugin/lib/sv_transfer_areas.lua:216Brings the transfer state of a player up to date by their position: forgets the areas they are not in any more or that have been removed, cancels a countdown whose area they have left, and ends a countdown whose time has come, which moves them when they are alive.
Parameters
- actor Player
- state Map the transfer state of the player
- stored Map every area, keyed by area ID
- cur_time Number current CurTime()
Builds a proxy command from a verb and its arguments, each quoted with
SrcdsProxy:quote. Arguments that are nil or empty are left out, so optional arguments
go last.
SrcdsProxy:verb('send', '76561198000000001', 'lobby', '')
-- 'send "76561198000000001" "lobby"'
Parameters
- name String the verb, such as 'info' or 'whitelist add', sent as it is
- ... Vararg arguments of the verb
Returns
- String