Skip to content

NilEis/Minecraft-server-query

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minecraft server query

A libary for querying minecraft servers using a protocol that is inspired by the UT3 query protocol.

API Reference

Initialization

    //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

How to get stats

There are two requests that can be made

Basic stats
    //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);
    }
Full stats
    //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);
    }

After usage

//Free allocated ressources
msq_free();

About

A libary written in C to query minecraft servers

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published