xealot 0 Posted November 8, 2014 (edited) Hello everyone. Me and a friend decided to make a stats system for our community in a small joint effort but interest seems to have faded but I have decided to share my arma side of the code. The complete source and compiled binaries can be found here: https://github.com/martinengstrom/arma_stat_track So what is this? Whilst the complete project is supposedly a stats tracker its basically just a c++ plugin written to send json formatted events to a webserver backend for storage, Of course you could alternatively just look at the code for educational purposes if you want as well. :) This plugin could be used for sending any kind of data to a remote server so it is perfect if you want to gather data real-time. The plugin is written with cross platform in mind and all of the functionality is platform independent with the sole exception of the library externs in main.cpp, I have yet to finalize this because I dont have a linux machine with arma 3 to test with. The API Please note that this was designed with the mission stat tracking purpose in mind but you are free to change the plugin however you need to. The communication consists of two stages, First the plugin will report that a mission has started and that it is ready and it expects an UID to be returned from the server. POST /api/missions { “nameâ€: “mission_name.altisâ€, “hostâ€: “NOT_IMPLEMENTEDâ€, “worldtâ€: “altisâ€, } and it expects the following return data: HTTP 201 { “_idâ€: 42 } _id should be the uid which the plugin will then use for every other packet it will transmit. Once the uid has been obtained the plugin is ready to start transmitting events. It will look like this: POST /api/missions/:id/events { "event": [ { "field1": "foo", "field2": "bar", "timestamp": "local-timestamp-from-server" }, { "field1": "foo", "field2": "bar", "timestamp": "local-timestamp-from-server" } ] } An event array may contain a single or multiple events depending on how quickly events are added to the library from arma, They will queue and be batch-sent when possible. Using the library in arma Here is the bare code needed to use the library in the game, taken from my github linked above: _hostname = "myserver.com"; xea_extension = "armastat"; // is global so other functions can access /* Configure the plugin and get status id */ xea_extension callExtension format["setup;%1", _hostname]; xea_stattrack_id = xea_extension callExtension format["status;%1", missionName]; // We dont really need to save the ID because its stored in the library anyway And then to send: xea_fnc_serializeArray = { _str = ""; for "_i" from 0 to (count _this) -1 do { _str = _str + format["%1=%2", (_this select _i) select 0, (_this select _i) select 1]; if (_i < ((count _this) -1)) then { _str = _str + ";"; }; }; _str } xea_fnc_sendEvent = { xea_extension callExtension format["event;%1", (_this call xea_fnc_serializeArray)]; }; _arr = [ ["field1", "foo"], ["field2", "bar"], ]; _arr call xea_fnc_sendEvent; This will produce an event as shown in the API example above. Do note that the timestamp is automatically added by the library before being sent. So thats it. I hope it may be of use to someone or at the very least provide some reading material. Criticism is welcome, Im a fairly novice C++ programmer so have at it! - xealot Edited November 8, 2014 by Xealot Share this post Link to post Share on other sites