Skip to content

A2S_PLAYER

Binary edited this page Dec 1, 2024 · 3 revisions

Synopsis

Emitting A2S_PLAYER server queries.

Example

#include <ssq/a2s.h>

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


uint8_t player_count;
A2S_PLAYER *players = ssq_player(server, &player_count);

/* Success */
if (ssq_server_eok(server)) {
    printf("There are %hhu players on the server:\n", player_count);
    for (uint8_t i = 0; i < player_count; ++i)
        printf("- %s with a score of %d\n", players[i].name, players[i].score);
    /* Cleanup */
    ssq_player_free(players, player_count);
}

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

Fields

Identifier Type Description
index uint8_t Index of player chunk starting from 0
name char * Name of the player
name_len size_t Length of the name string
score int32_t Player's score (usually "frags" or "kills")
duration float Time (in seconds) player has been connected to the server

Functions

ssq_player

Retrieves information about the players currently on the server.

Parameters

Name Type Nullable Description
server SSQ_SERVER * Source server instance to query
player_count uint8_t * Number of players in the response

Return value

Returns an A2S_PLAYER response array of length *player_count which must be freed using ssq_player_free.

⚠️ In case there are no players in the response, returns NULL.

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

ssq_player_free

Frees an A2S_PLAYER response array returned by ssq_player.

Parameters

Name Type Nullable Description
players A2S_PLAYER * A2S_PLAYER response array to free
player_count uint8_t Number of players in the array
Clone this wiki locally