Skip to content

A2S_INFO

Binary edited this page Dec 1, 2024 · 3 revisions

Synopsis

Emitting A2S_INFO server queries.

Example

#include <ssq/a2s.h>

// See the `SSQ_SERVER' wiki page.
SSQ_SERVER *server;


A2S_INFO *info = ssq_info(server);

/* Success */
if (ssq_server_eok(server)) {
    printf("Players: %hhu/%hhu\n", info->players, info->max_players);
    if (ssq_info_has_keywords(info))
        printf("Keywords: %s\n", info->keywords);
    /* Cleanup */
    ssq_info_free(info);
}

/* Failure */
if (!ssq_server_eok(server)) {
    fprintf(stderr, "ssq_info: %s\n", ssq_server_emsg(server));
    /* Cleanup */
    ssq_server_eclr(server);
}

Fields

Identifier Type Optional Description
protocol uint8_t Protocol version used by the server
name char * Name of the server
name_len size_t Length of the name string
map char * Map the server has currently loaded
map_len size_t Length of the map string
folder char * Name of the folder containing the game files
folder_len size_t Length of the folder string
game char * Full name of the game
game_len char * Length of the game string
id uint16_t Steam Application ID of game
players uint8_t Number of players on the server
max_players uint8_t Maximum number of players the server reports it can hold
bots uint8_t Number of bots on the server
server_type A2S_SERVER_TYPE The type of server
environment A2S_ENVIRONMENT The operating system of the server
visibility bool Whether the server requires a password
vac bool Whether the server uses VAC
version char * Version of the game installed on the server
version_len size_t Length of the version string
edf uint8_t Extra Data Flag
port uint16_t The server's game port number
steamid uint64_t Server's SteamID
stv_port uint16_t Spectator port number for SourceTV
stv_name char * Name of the spectator server for SourceTV
stv_name_len size_t Length of the stv_name string
keywords char * Tags that describe the game according to the server
keywords_len size_t Length of the keywords string
gameid uint64_t The server's 64-bit Game ID

Optional Fields

Helper functions are available to check if an optional field is present.

Field Helper function
port ssq_info_has_port
steamid ssq_info_has_steamid
stv_port ssq_info_has_stv
stv_name ssq_info_has_stv
stv_name_len ssq_info_has_stv
keywords ssq_info_has_keywords
keywords_len ssq_info_has_keywords
gameid ssq_info_has_gameid

Enums

A2S_SERVER_TYPE

Name Description
A2S_SERVER_TYPE_DEDICATED The server is a dedicated server
A2S_SERVER_TYPE_NON_DEDICATED The server is a non-dedicated server
A2S_SERVER_TYPE_STV_RELAY The server is a SourceTV relay (proxy)
A2S_SERVER_TYPE_UNKNOWN Unknown server type

A2S_ENVIRONMENT

Name Description
A2S_ENVIRONMENT_LINUX The server runs on Linux
A2S_ENVIRONMENT_WINDOWS The server runs on Windows
A2S_ENVIRONMENT_MAC The server runs on Mac
A2S_ENVIRONMENT_UNKNOWN Unknown operating system

Functions

ssq_info

Retrieves information about the server including, but not limited to: its name, the map currently being played, and the number of players.

Parameters

Name Type Nullable Description
server SSQ_SERVER * Source server instance to query

Return value

Returns an A2S_INFO response which must be freed using ssq_info_free.

⚠️ In case of an error, returns NULL and updates the last error of server.

ssq_info_free

Frees an A2S_INFO response returned by ssq_info.

Parameters

Name Type Nullable Description
info A2S_INFO * A2S_INFO response to free
Clone this wiki locally