Skip to content

A module used to interact with a web site for score and server list uploads and downloads

Notifications You must be signed in to change notification settings

NewCreature/T3Net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview
--------

T3Net provides code for interacting with a web site from a native program. It
relies on libcurl to do HTTP requests. T3Net can take specifically formatted
data and parse it into easily usable data sets.


The C Side
----------

To get a dataset you simply call t3net_get_data(my_url). You will get a pointer
to a T3NET_DATA structure in return. This data structure has arrays of entries
and fields which can be easily utilized in your programs.

If you are retrieving a list of high scores, for instance, you can do something
like this:

T3NET_DATA * score_list;
int i;

score_list = t3net_get_data(url_to_score_script);
if(score_list)
{
    for(i = 0; i < score_list->entries; i++)
    {
        printf("%d. %s - %s\n", i + 1, score_list->entry[i]->field[0]->data, score_list->entry[i]->field[1]->data);
    }
}


The PHP Side
------------

A template is provided to help you get started. T3Net expects your script to
output data in this format:

Example Header\r\n
\r\n
\tfield_name_1: data1\r\n
\tfield_name_2: data2\r\n
\r\n
\tfield_name_1: data3\r\n
\tfield_name_2: data4\r\n

The script is self-explanatory. You just need to put in the correct database
info and make the data in the arrays match what is in your database.

Let's say you have a database with this structure:

my_dabatase
-leaderboards
 -game
 -name
 -score

The database in the script should be set up like this:

$db_database = "my_database";
$db_name = "leaderboards";
$db_fields = array('game', 'name', 'score');

The output section should be set up like this:

$output_fields = array('name', 'score');

The settings should be set up like this:

$order_field = "score";

When you access this script through T3Net with the URL like this:

score_list = t3net_get_data("http://www.site.com/my_script.php?game=my_game");

you will get a data set containing all of the scores in the database where the
game field is set to "my_game" in order form highest to lowest.

You can change how the data is generated by passing arguments in the URL:

score_list = t3net_get_data("http://www.site.com/my_script.php?game=my_game&ascend=true&limit=10");

This set of arguments will sort the scores from lowest to highest and only
output 10 entries.

About

A module used to interact with a web site for score and server list uploads and downloads

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published