A libary for querying minecraft servers using a protocol that is inspired by the UT3 query protocol.
//Initialize the libary and check for errors
int ret = msq_init(SERVER_IP, PORT);
if (ret != 0)
{
printf("Error: %s\n", msq_get_error(ret));
}
Parameter | Type | Example | Description |
---|---|---|---|
SERVER_IP |
const char* |
"localhost" |
The ip address of the server |
PORT |
int |
25565 |
The query port of the server |
There are two requests that can be made
//The struct will be used to receive server stats
msq_basic_stats_t basic_stats_struct;
//Get the stats and check for errors
ret = msq_get_basic_stats(&basic_stats_struct);
if (ret != 0)
{
printf("Error: %s\n", msq_get_error(ret));
}
else
{
//If the request was successful, print the stats
//and free allocated memory
msq_print_basic_stats(&basic_stats_struct);
msq_free_basic_stats(&basic_stats_struct);
}
//The struct will be used to receive full server stats
msq_full_stats_t full_stats_struct;
//Get the stats and check for errors
ret = msq_get_full_stats(&basic_full_struct);
if (ret != 0)
{
printf("Error: %s\n", msq_get_error(ret));
}
else
{
//If the request was successful, print the stats
//and free allocated memory
msq_print_full_stats(&full_stats_struct);
msq_free_full_stats(&full_stats_struct);
}
//Free allocated ressources
msq_free();