The sakaSTATS.inc include file provides a comprehensive API for interacting with the sakaSTATS plugin from other SourceMod plugins. This allows developers to access player statistics, rankings, and seasonal data across the entire saka ecosystem.
- Place
sakaSTATS.incin yoursourcemod/scripting/include/directory - Include it in your plugin:
#include <sakaSTATS> - Ensure the sakaSTATS plugin is loaded on your server
#define SAKASTATS_STAT_POINTS "points"
#define SAKASTATS_STAT_KILLS "kills"
#define SAKASTATS_STAT_DEATHS "deaths"
#define SAKASTATS_STAT_PLAYTIME "playtime"
#define SAKASTATS_STAT_TOPSPEED "topspeed"
#define SAKASTATS_STAT_DEFLECTIONS "deflections"#define SAKASTATS_MAX_NAME_LENGTH 128
#define SAKASTATS_MAX_STEAMID_LENGTH 64
#define SAKASTATS_INVALID_RANK -1
#define SAKASTATS_CURRENT_SEASON 0The legacy scalar reads are compatibility shims: they read confirmed local state and fail closed on a cache miss. They never wait for MySQL. Consumers that require an authoritative remote result should use the asynchronous request natives below.
Gets a player's statistic value for the current season.
- Parameters:
steamid- Player's SteamID (Steam3 format: [U:1:XXXXXXX])statistic- Statistic name (use SAKASTATS_STAT_* constants)
- Returns: Statistic value, -1 on error
Gets a player's statistic value for a specific season.
- Parameters:
steamid- Player's SteamIDstatistic- Statistic nameseason- Season number (0 for current season)
- Returns: Statistic value, -1 on error
Gets a player's ranking for a statistic in the current season.
- Parameters:
steamid- Player's SteamIDstatistic- Statistic name
- Returns: Player's rank (1-based), SAKASTATS_INVALID_RANK on error
Gets a player's ranking for a statistic in a specific season.
- Parameters:
steamid- Player's SteamIDstatistic- Statistic nameseason- Season number (0 for current season)
- Returns: Player's rank (1-based), SAKASTATS_INVALID_RANK on error
Queues an authoritative competition-rank query. Returns a positive request ID
when accepted and invokes the callback exactly once with a
SakaStatsAsyncResult, rank, and caller data.
Queues an authoritative live-profile query. Returns a positive request ID when accepted and invokes the callback exactly once with the display name, remaining name changes, result status, and caller data.
Queues an authoritative existence query and completes once with the SteamID, existence flag, result status, and caller data.
Queues an authoritative statistic query and completes once with the typed result, value, request identity, and caller data.
Queues an authoritative season count. The live season returns active players from the last 30 days; archived seasons return their total row count.
Gets the current season number.
- Returns: Current season number
Checks if the season system is enabled.
- Returns: True if season system is enabled, false otherwise
Gets a player's display name (custom name if set, otherwise Steam name).
- Parameters:
steamid- Player's SteamIDname- Buffer to store the namemaxlen- Maximum length of buffer
- Returns: True on success, false on error
Gets a player's remaining name changes.
- Parameters:
steamid- Player's SteamID
- Returns: Number of remaining name changes, -1 on error
Calculates Kills per Hour for given stats.
- Parameters:
kills- Number of killsplaytime- Playtime in seconds
- Returns: Kills per hour
Gets the total number of players in the database.
- Returns: Total player count, -1 on error
Checks if a player exists in the database.
- Parameters:
steamid- Player's SteamID
- Returns: True if player exists, false otherwise
Gets the tracked rockets-stolen count for a connected client.
- Parameters:
client- Client index
- Returns: Rockets stolen count, 0 on error
The following immediate reads have stock wrappers accepting client indices. Async requests still take SteamIDs; capture a userid or serial in caller data and revalidate the recipient before displaying a callback result:
SakaStats_GetClientStat(client, statistic)SakaStats_GetClientStatSeason(client, statistic, season)SakaStats_GetClientRank(client, statistic)SakaStats_GetClientRankSeason(client, statistic, season)SakaStats_GetClientDisplayName(client, name, maxlen)SakaStats_GetClientNameChanges(client)SakaStats_ClientExists(client)SakaStats_GetClientRocketsStolen(client)
Validates a client index.
- Returns: True if client is valid, false otherwise
Gets a client's SteamID in Steam3 format.
- Returns: True on success, false on failure
Formats playtime from seconds to readable string.
- Example: 3661 seconds → "1h1m1s"
Calculates K/D ratio with proper handling of zero deaths.
- Returns: K/D ratio
Formats Kills per Hour for display.
These fragments demonstrate cache-only reads. Handle unavailable values before displaying them; a prior existence check does not guarantee that rank or other fields are cached. Use asynchronous requests for authoritative results.
#include <sakaSTATS>
public Action Command_MyStats(int client, int args) {
if (!SakaStats_ClientExists(client)) {
PrintToChat(client, "No statistics found!");
return Plugin_Handled;
}
int points = SakaStats_GetClientStat(client, SAKASTATS_STAT_POINTS);
int rank = SakaStats_GetClientRank(client, SAKASTATS_STAT_POINTS);
PrintToChat(client, "Points: %d (Rank #%d)", points, rank);
return Plugin_Handled;
}public Action Command_SeasonStats(int client, int args) {
if (!SakaStats_IsSeasonSystemEnabled()) {
PrintToChat(client, "Season system is disabled!");
return Plugin_Handled;
}
int currentSeason = SakaStats_GetCurrentSeason();
int seasonPoints = SakaStats_GetClientStatSeason(client, SAKASTATS_STAT_POINTS, currentSeason);
PrintToChat(client, "Season %d Points: %d", currentSeason, seasonPoints);
return Plugin_Handled;
}public void ComparePlayersStats(int client1, int client2) {
int points1 = SakaStats_GetClientStat(client1, SAKASTATS_STAT_POINTS);
int points2 = SakaStats_GetClientStat(client2, SAKASTATS_STAT_POINTS);
char name1[SAKASTATS_MAX_NAME_LENGTH], name2[SAKASTATS_MAX_NAME_LENGTH];
SakaStats_GetClientDisplayName(client1, name1, sizeof(name1));
SakaStats_GetClientDisplayName(client2, name2, sizeof(name2));
PrintToChatAll("%s (%d) vs %s (%d)", name1, points1, name2, points2);
}There are currently no in-repository plugin consumers of this public API.
External consumers should use the contract reference
and the signatures in sakaSTATS.inc. The older references to
sakaBOT, sakaROBOT, and sakaCOLORSv2 are not current integration examples.
Always check each native's documented return value:
- Legacy stat/rank/name-change reads use -1 for unavailable data.
- Async requests return 0 when not accepted; inspect
SakaStatsAsyncResultin callbacks for accepted requests. - Rockets-stolen reads return 0 on invalid input.
- A false cache-only existence result can mean unconfirmed data, not necessarily
an absent database row. Use
SakaStats_RequestPlayerExistswhen that distinction matters.
- Use the async request natives for authoritative database reads.
- Immediate legacy calls are safe in gameplay callbacks because they never execute network SQL; always handle their fail-closed sentinel.
See the compiled API consumer fixture
for signature coverage. It is a compile-time fixture, not a deployable gameplay
example; the previously referenced examples/sakaSTATS_example.sp is not present.