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

Adds the Server Transfer Area mode to the Area Tool.
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.
Hands the addon's commands over to Flux once every addon and the gamemode have loaded.
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.
Forgets the transfer state of a player who leaves the server.

Methods

Checks whether the srcdsproxy backend addon is installed, that is whether its Proxy table exists.
Has the proxy ban targets from the whole network on behalf of the caller, who has to be a proxy admin.
Stops the countdown of a player, if one runs, and takes it off their HUD.
Checks whether the srcdsproxy backend addon is installed and tells the caller that it is missing if it is not.
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.
Deals with a player who has entered a transfer area.
Starts 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.
Finds the player on this server whom the proxy knows by a SteamID64 or by a SteamID3 ([U:1:123]).
Finds whom a player argument of a proxy command targets, as IDs the proxy understands.
Ends the countdown of a player: moves them if they are alive, which the caller has checked them to be in the area too.
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.
Checks whether a player is on the named server of the network already.
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.
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.
Finds 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.
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.
Checks whether the caller is a proxy admin: listed in the proxy's admins.toml and verified by Steam.
Sends one or more commands to the proxy on behalf of the caller, who has to be connected through the proxy.
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.
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.
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.
Turns a value into the delay of a transfer area: a number of seconds from 0 to SrcdsProxy.max_transfer_delay.
Moves 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.
Brings 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.
Builds a proxy command from a verb and its arguments, each quoted with SrcdsProxy:quote.

Hooks

SrcdsProxy:AddAreaToolModes(mode_list)

shared plugins/srcdsproxy/plugin/sh_hooks.lua:89

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

SrcdsProxy:FLHUDPaint(cur_time, scrw)

client plugins/srcdsproxy/plugin/cl_hooks.lua:17

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

SrcdsProxy:Initialize()

server plugins/srcdsproxy/plugin/sv_hooks.lua:76

Hands the addon's commands over to Flux once every addon and the gamemode have loaded.

SrcdsProxy:LazyTick()

server plugins/srcdsproxy/plugin/sv_hooks.lua:88

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.

SrcdsProxy:OnReloaded()

server plugins/srcdsproxy/plugin/sv_hooks.lua:81

Hands the addon's commands over to Flux again after a Lua refresh.

SrcdsProxy:PlayerDisconnected(actor)

server plugins/srcdsproxy/plugin/sv_hooks.lua:114

Implements hook PlayerDisconnected

Forgets the transfer state of a player who leaves the server.

Parameters

  • actor Player

Methods

SrcdsProxy:available()

server plugins/srcdsproxy/plugin/sv_plugin.lua:10

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:337

Has 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 nil ban duration, or the first word of the reason
  • reason String optional, defaults to nil the 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:103

Stops 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

SrcdsProxy:check_available(actor)

server plugins/srcdsproxy/plugin/sv_plugin.lua:18

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

SrcdsProxy:check_proxied(actor)

server plugins/srcdsproxy/plugin/sv_plugin.lua:33

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:119

Deals 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:251

Starts 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

SrcdsProxy:find_local_steam_id(argument)

server plugins/srcdsproxy/plugin/sv_plugin.lua:160

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:224

Finds 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 false check the immunity of the players on this server

Returns

  • List<Map> entries with the id (String) to give to the proxy and the player (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:196

Ends 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

SrcdsProxy:is_address(text)

server plugins/srcdsproxy/plugin/sv_plugin.lua:114

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:73

Checks 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

SrcdsProxy:is_duration(text)

server plugins/srcdsproxy/plugin/sv_plugin.lua:139

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

SrcdsProxy:may_enter(actor, backend)

server plugins/srcdsproxy/plugin/lib/sv_transfer_areas.lua:83

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:41

Finds 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

Returns

  • String

SrcdsProxy:quote(text)

server plugins/srcdsproxy/plugin/sv_plugin.lua:75

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

SrcdsProxy:require_proxy_admin(actor)

server plugins/srcdsproxy/plugin/sv_plugin.lua:52

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

SrcdsProxy:run(actor, verbs)

server plugins/srcdsproxy/plugin/sv_plugin.lua:186

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

SrcdsProxy:server_name(text)

shared plugins/srcdsproxy/plugin/lib/sh_transfer_areas.lua:18

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

SrcdsProxy:take_over()

server plugins/srcdsproxy/plugin/sv_hooks.lua:54

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.

SrcdsProxy:targets_to_string(entries)

server plugins/srcdsproxy/plugin/sv_plugin.lua:318

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

SrcdsProxy:transfer_delay(value)

shared plugins/srcdsproxy/plugin/lib/sh_transfer_areas.lua:32

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_delay if the value is no number

SrcdsProxy:transfer_from_area(actor, area)

server plugins/srcdsproxy/plugin/lib/sv_transfer_areas.lua:160

Moves 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:216

Brings 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()

SrcdsProxy:verb(name, ...)

server plugins/srcdsproxy/plugin/sv_plugin.lua:91

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

Defined in