Skip to content

Navigation Menu

Sign in
Sign up

A2S_PLAYER

Binary edited this page Oct 30, 2022 · 3 revisions

Synopsis

Structure reflecting the response of an A2S_PLAYER query.

Example

#include <ssq/a2s.h>
#include <inttypes.h>
#include <stdio.h>
SSQ_SERVER server;
// ...
uint8_t player_count = 0;
A2S_PLAYER *players = ssq_player(&server, &player_count);
if (ssq_server_ok(&server)) {
 printf("There are %" PRIu8 " players currently on the server:\n", player_count);
 for (uint8_t i = 0; i < player_count; ++i)
 printf("%s (score: %" PRId32 ")\n", players[i].name, players[i].score);
 ssq_player_free(players, player_count);
} else {
 // ...
}
// ...

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

Send an A2S_PLAYER query to a Source game server.

Arguments

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

Return value

Returns NULL when an error occurs or there are no players currently on the server, otherwise returns an A2S_PLAYER structure array of size *player_count containing details about each player.

Notes

⚠️ The A2S_PLAYER structure array must be freed with ssq_player_free when done using it.

⚠️ When an error occurs, it must be cleared with ssq_server_err_clr when done handling it.

ssq_player_free

Free an A2S_PLAYER structure array.

Arguments

Name Type Nullable Description
players A2S_PLAYER * no A2S_PLAYER structure array to free.
player_count uint8_t Number of players in the array.

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /