← Go back

ArmaDB - MySql and MariaDB plugin for Arma 3 server side mods

Posted on April 15, 2018 at 23:55 (GMT +00:00) by Colin

I've been quiet for these past weeks months as I've been very busy working on some projects for my non-profit organisation One Nature, I have also been using some of my spare time to play a bit of Elite Dangerous! However I made a bit time recently to put together a mysql/mariadb plugin for Arma server which can be used for saving persistent information across missions etc.

The current development of the plugin covers only the windows 32-bit dedicated server software, but I will update this to include 64-bit hopefully very soon. I have tried to keep it as plain and simple as possible, so it can be used like the regular mysql implementations. I have uploaded a sample mod that can be used server side, it should be extracted to your arma installation directory (see the bottom of the post).

Here is a quick sample mod that uses the plugin (please note you will need to create yourself a database and change connection settings. If you have problems, just drop me a message.

// PXSample mod

#include "PX\mysql.sqf";

// init db ?
[] call mysql_init;
mydb = ['root', 'yourpassword', 'databasename', 'localhost', 3306] call mysql_connect;

addMissionEventHandler ["EntityRespawned", {
	params ["_obj", "_old"];
	private ["_result", "_resource", "_row", "_uid"];
	if (isPlayer _obj) then {	
		_uid = getPlayerUID _obj;
		_result = [mydb, "SELECT acc_uid FROM accounts WHERE acc_uid = '%1' LIMIT 1;", _uid] call mysql_query;
		if (_result == "") then {
			_resource = [mydb] call mysql_store_result;
			if (!(_resource == "")) then {
				_row = [_resource] call mysql_fetch_row;
				if (count _row > 0) then {
					// player exists already? do something maybe
				} else {	
					[mydb, "INSERT INTO accounts(acc_uid, acc_clientname, acc_last_conn_dt) VALUES('%1','%2',NOW());", _uid, name _obj] call mysql_query;
			[_resource] call mysql_free_result;			

and note, this should only be used on a server side mod (not in a mission file, since you don't want your database password visible to players)

Download Plugin and Sample Mod here
/Scripting/Programming/Game Modding