← 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

Search
Tags
Accident Adoption Albums Algorithms Altcoins Animal Rescue AnL Aquarium Arma ArmA nd Leg Array Partitioning Arrays Assembler Assembly Atanasovsko Award Bazaar Binary Search Bitcoin Bohemia Bootstrap Bulgaria Bulgaria Za Mladite Burgas C C++ Celerity Charity Chemical Records Chemical Shock Chemlight Code Competition Compiler Contest Converter Covid-19 CPP Crypto Cryptocurrency css Data Recovery Database DataTables Decode Dedicated Dedicated Server Delphi Development Dialogs Divide & Conquer DIY DnB Drum & Bass Earplugs Event Exchange Eyes Fish Floating-point Flood Fog Freeware Function Funny Gallery Game Game Development Game Modding Gaming Garden Gardening Gazebo GERB GitHub Glitch Hamish Harding Happy New Year Heapify HeapSort Helga HTML HTML entities Introduction Jackie JavaScript JQuery Jungle Lake Language Linker Listbox ListNBox lnbSetTooltip MariaDB Maths Merry Christmas Mini Mining Miningpoolhub Mist Modding MPH Multiplayer Music MySql NGO OceanGate One Nature ORCA organisation OverHertz Paludarium Pandemic Pascal Paul-Henri Nargeolet Paws Furever Pergola Persistence Pets Photography Pier Plugin Programming progress bar Project PX Library Quicksort r53 Racing Replace Scripting Searching Server Shahzada Dawood Simulation Simulator Smoke Snippet Social media Software Sorting Source Sourcecode SQF Statistics Stockton Rush String Strings Submarine Suleman Dawood Terrain Detail Text Titan Tool Tragedy tutorial UCS4Char UE4 Unreal Engine Victims View Distance ViewBug web Web Development Website Welcome Woodworking Ziron Zynk