# ArmA2 Persistent Database Scripts - WIP

## Recommended Posts

Everything seems to be working on domination only problem it keeps going to a black screen and wont go around it only error I get it this.

Arma2OA.rpt

["PersistentDB: SPAWN"]


Main.sqf

// ====================================================================================
// PDB STARTUP
if ((!isServer) && (player != player)) then { waitUntil {player == player};};

if ((!isServer) || (!isdedicated)) then {

[] spawn {
waitUntil { !(isNull player) };
sleep 0.2;
[color="#FF0000"]diag_log["PersistentDB: SPAWN"];[/color]
player setVariable ["BIS_noCoreConversations", true];
player addeventhandler ["Dammaged", { _this call persistent_fnc_playerDamage; } ];
player addeventhandler ["animChanged", { _this call persistent_fnc_playerHeal; } ];
player addeventhandler ["Respawn", { _this call persistent_fnc_playerRespawn; } ];
player addeventhandler ["Fired", { _this call persistent_fnc_playerFired; } ];
player allowdamage false;
processInitCommands;
finishMissionInit;
waituntil { (PDB_PLAYERS_CONNECTED select 0 == "000000") };  // wait until server has finished loading data
waituntil {time > 3};
_thistime = time; waituntil { time > (random 5) + _thistime };
diag_log["PersistentDB: FINISHED MISSION INIT, time: ", time];
waituntil { (MISSIONDATA_LOADED == "true") };
PDB_PLAYER_READY = [getPlayerUID player, player, name player, playerside];
};
};
// ====================================================================================


I don't think its able to find what its looking for in the dialog.hpp.

Edited by diesol

##### Share on other sites

Forget about my last post I found something easier to put on the server. Just need a little help I am running Arma2Net 2.2 and I am trying to install the domdatabase. This is what I am going off of https://dev-heaven.net/issues/38080.

Everything works but it wont save score.

01/15/2013 03:36:49 Arma2NET 2.3.0.0 running on CLR 4.0.30319.296
01/15/2013 03:36:49 Loaded into process arma2oaserver
01/15/2013 03:36:49 Found an assembly inside the add-in base directory. If this assembly is an add-in, place it inside an add-in subdirectory: C:\Program Files (x86)\Steam\steamapps\common\Arma 2 Operation Arrowhead\@Arma2NET\AddIns\Arma2Net.Managed.dll
01/15/2013 03:36:49 Domain                        Name                Version   Publisher           Description
01/15/2013 03:36:49 DefaultDomain                 ClrVersion          2.0.0.0   Scott_NZ            Retrieves the version of the Common Language Runtime.
01/15/2013 03:36:49 DefaultDomain                 CompareVersion      2.0.0.0   Scott_NZ            Compares two version strings and returns an integer indicating how they compare.
01/15/2013 03:36:49 DefaultDomain                 Version             2.0.0.0   Scott_NZ            Returns the version of Arma2NET.
01/15/2013 03:36:49 DefaultDomain                 GetClipboardText    1.0.0.0   Scott_NZ            Gets the clipboard text value.
01/15/2013 03:36:49 DefaultDomain                 SetClipboardText    1.0.0.0   Scott_NZ            Sets the clipboard to a text value.
01/15/2013 03:36:49 DefaultDomain                 CommandLine         2.0.0.0   Scott_NZ            Returns the command line used to start the application.
01/15/2013 03:36:49 DefaultDomain                 DateTime            2.0.0.0   Scott_NZ            Returns the current date and time.
01/15/2013 03:36:49 DefaultDomain                 DomDatabase         1.0.0.0   Xeno                Domination Database.
01/15/2013 03:36:49 Arma2NET initialized in 00:00:00.0804765
01/15/2013 03:36:49 function: DomDatabase ['Init','DomDatabase','Dom.db']
01/15/2013 03:36:49 maxResultSize: 10239
01/15/2013 03:36:49 Result size: 2
01/15/2013 03:36:49 Result: []
01/15/2013 03:36:50 function: DomDatabase ['Servername']
01/15/2013 03:36:50 maxResultSize: 10239
01/15/2013 03:36:50 Result size: 0
01/15/2013 03:36:50 Result:
01/15/2013 03:37:08 function: DomDatabase ['Read', '5756102','Diesel']
01/15/2013 03:37:08 maxResultSize: 10239
01/15/2013 03:37:08 Result size: 68
01/15/2013 03:37:08 Result: ["5756102", "Diesel", 0, 580, 0, 0, 9, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0]
01/15/2013 03:45:12 function: DomDatabase ['Write','5756102','Diesel',0, 1063, 0, 0, 18, 0, 2, 2, 3, 0, 0, 0, 0, 0, 0]
01/15/2013 03:45:12 maxResultSize: 10239
01/15/2013 03:45:12 Result size: 2
01/15/2013 03:45:12 Result: []
01/15/2013 03:45:48 function: DomDatabase ['Read', '5756102','Diesel']
01/15/2013 03:45:48 maxResultSize: 10239
01/15/2013 03:45:48 Result size: 70
01/15/2013 03:45:48 Result: ["5756102", "Diesel", 0, 1063, 0, 0, 18, 0, 2, 2, 3, 0, 0, 0, 0, 0, 0]
01/15/2013 03:46:48 function: DomDatabase ['Write','5756102','Diesel',0, 1124, 0, 1, 18, 0, 2, 2, 3, 0, 0, 0, 0, 0, 0]
01/15/2013 03:46:48 maxResultSize: 10239
01/15/2013 03:46:48 Result size: 2
01/15/2013 03:46:48 Result: []


Edited by diesol

##### Share on other sites

Hey all, so I was wondering if someone could maybe help me through setting all this up? I have my personal server setup and play online with some friends doing different missions but with some missions it gets old having to restart. The only problem I am having with this is...I don't really understand how to install/setup this stuff to be able to save our progress. Any and all help is much appreciated!!!

##### Share on other sites

@keyboardnutz

There are many issues and bugs in the current PDB standalone version. Development of the standalone PDB scripts has ceased and I have moved development be to exclusively for MSO where PDB development has really moved on massively in MSO 4.6. Myself and the MSO dev team will also be working on a new MSO PDB version for Arma3 when it's released which will be in addon form.

I am no longer offering support for this old standalone version of PDB.

You can get support for the new PDB integrated into MSO on our dev-heaven site here

MSO support is here and here

The latest development files can be found here

Might I suggest that an site admin locks this thread since it's now legacy.

Edited by [KH]Jman

##### Share on other sites

Thanks for the quick reply Jman, I was just having a hard time figuring it out cause I'm not all that experienced with scripting and dealing with internals of games (self taught) but I do appreciate it. Now, will the MSO PDB help out in my case? Just being able to save on the server I run?

Edit: I reread through that and had another question, I'm assuming that is a mission of some sort that you have integrated your PDB into? I'm probably way off haha

Edited by keyboardnutz

##### Share on other sites

Ok I checked out the sight for the new files and it's saying I am not authorized to view the files? I really would like to just figure this out :) Thanks for any help. Sorry for so many questions.

##### Share on other sites
Hey all, so I was wondering if someone could maybe help me through setting all this up? I have my personal server setup and play online with some friends doing different missions but with some missions it gets old having to restart. The only problem I am having with this is...I don't really understand how to install/setup this stuff to be able to save our progress. Any and all help is much appreciated!!!

I would try at Kelly's Heroes first they have a guide to installing PDB and post specifics here later if required.

a tip I would offer is DO keep it very very basic to start with so that you don't make it too complicated.

Edited by bkgfernando

##### Share on other sites

Thanks man, I read through it and went step by step to set it up. In the process of doing it now. One question, do you prefer .msi or .zip version of these files? Does it make a difference? Maybe more ability to move around the contents of the .zip? Also what does it mean "install these files to your windows server". Just to be sure I understand it.

Edit: I got into MySQL and set it up...there is so much more than I thought, I mean I want to learn how to use it but can't find any guides on working through MySQL and what exactly it is I guess. Excuse my lack of intelligence haha

Edited by keyboardnutz

##### Share on other sites

pm sent keyboardnutz.

##### Share on other sites

using this add with a wasteland mission would it save it? if so cool.

##### Share on other sites

keyboardnutz - i had same problem - however bag yourself a simple book on SQL

i got this and it helped loads http://www.amazon.co.uk/SQL-Easy-Steps-3rd-Edition/dp/1840785438/ref=sr_1_1?ie=UTF8&qid=1361290721&sr=8-1

ive now implemented my own save system - score, position etc. Brilliant tool :)

##### Share on other sites

Ok, I got the database set up and the example mission working. Now I'm looking to personalize it a bit and am hoping someone is willing to confirm whether or not I am looking in the right place, and provide clarification on anything I might have missed (or if I am way off here).

I've been skimming through the code in the example missions and looking at the tables in the MySql DB all day and I think I've figured out where the code "transitions" from ARMA 2 (sqf) to MySql (sql), at least where I am interested (for the players):

ARMA 2: player.sqf

MySql: PersistentDB.sql

So, if I have other custom player variables in a mission (money, virtual inventory items, etc) that I want recorded into the DB under table "players", I think I would need to do something like this (code is not meant to be specific at this point, but trying to understand the logic):

- Create a new field in the MySql DB table for what I am trying to keep track of (EX: "mon" for money)

- Add "mon" in PersistentDB.sql here:

CREATE TABLE players (

id int(11) NOT NULL AUTO_INCREMENT,

na varchar(255) NOT NULL DEFAULT '',

pid int(11) NOT NULL,

sc int(11) DEFAULT '0',

pos varchar(255) DEFAULT NULL,

wea varchar(1000) DEFAULT '',

mag varchar(1000) DEFAULT '',

mid int(11) DEFAULT NULL,

dam float DEFAULT '0',

dhe float DEFAULT '0',

dbo float DEFAULT '0',

dha float DEFAULT '0',

dle float DEFAULT '0',

dir float DEFAULT '0',

sta varchar(10) DEFAULT 'Stand',

sid varchar(10) DEFAULT NULL,

veh varchar(255) DEFAULT '',

sea varchar(10) DEFAULT '',

awb varchar(1000) DEFAULT '',

arc varchar(45) DEFAULT '',

aw varchar(1000) DEFAULT '',

arm varchar(1000) DEFAULT '',

typ varchar(45) DEFAULT '',

rat int(11) DEFAULT '0',

vd int(11) DEFAULT '1600',

td int(11) DEFAULT '0',

ran varchar(45) DEFAULT '',

fir int(11) DEFAULT '0',

ek int(11) DEFAULT '0',

ck int(11) DEFAULT '0',

fk int(11) DEFAULT '0',

sui int(11) DEFAULT '0',

lif varchar(45) DEFAULT 'ALIVE',

dea int(11) DEFAULT '0',

tp int(11) DEFAULT '0',

grp varchar(45) DEFAULT '',

rck varchar(45) DEFAULT '',

rwe varchar(1000) DEFAULT '',

rma varchar(1000) DEFAULT '',

lc varchar(45) DEFAULT '',

ld varchar(45) DEFAULT '',

mon int(11) DEFAULT '0',

- Add 'mon' and sqf variant ('tmon' for this example) in PersistentDB.sql here:

BEGIN

UPDATE players SET sc = tsc, pos = tpos, dam = tdam, dhe = tdhe, dbo = tdbo, dha = tdha, dle = tdle, dir = tdir, sta = tsta, sid = tsid, veh = tveh, sea = tsea, typ = ttyp, rat = trat, vd = tvd, td = ttd, ran = tran, fir = tfir, ek = tek, ck = tck, fk = tfk, sui = tsui, lif = tlif, dea = tdea, tp = ttp, lc = tlc, ld = tld WHERE pid = tpid AND na = tna AND mid = tmid, mon = tmon;

END */;;

DELIMITER ;

/*!50003 SET sql_mode = @saved_sql_mode */ ;

/*!50003 SET character_set_client = @saved_cs_client */ ;

/*!50003 SET character_set_results = @saved_cs_results */ ;

/*!50003 SET collation_connection = @saved_col_connection */ ;

/*!50003 DROP PROCEDURE IF EXISTS UpdatePlayerACE */;

/*!50003 SET @saved_cs_client = @@character_set_client */ ;

/*!50003 SET @saved_cs_results = @@character_set_results */ ;

/*!50003 SET @saved_col_connection = @@collation_connection */ ;

/*!50003 SET character_set_client = utf8 */ ;

/*!50003 SET character_set_results = utf8 */ ;

/*!50003 SET collation_connection = utf8_general_ci */ ;

/*!50003 SET @saved_sql_mode = @@sql_mode */ ;

/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;

DELIMITER ;;

- Add 'tmon' to the following list in player.sqf:

G_PLAYER_DATA_PARAMS = ["tsc","tpos","tdam","tdhe","tdbo","tdha","tdle","tdir","tsta","tsid","tveh","tsea","ttyp","trat","tvd","ttd","tran","tfir","tek","tck","tfk","tsui","tlif","tdea","ttp","tlc","tld","tmon"];

- Add the following at the end of the G_PLAYER_DATA list (since I added 'tmon' to the end of the above array, and assuming I have set pmoney as the variable in the rest of my mission code that tracks the amount of money a player has):

{ (_this select 0) getVariable "pmoney";},

- Finally, add the following at the end of the S_PLAYER_DATA list:

{(_this select 1) setVariable ["pmoney", (_this select 0), true];}

Assuming I have set the variable for money to "pmoney" in the rest of my mission files, does this look about right to get the money data stored in the DB for each player?

Any feedback is welcome! :D

Edited by VAKE
Fixing my drunken-typing-style kata!

##### Share on other sites

I am attempting to establish a persistent Insurgency mission however I get an error. I believe I had gotten this error when trying to set up PDB for an MSO mission as well but I do not remember how to get around it.

Here are my log files and RPT. If anyone could help it would be greatly appreciated.

Arma2Net Log: http://pastebin.com/JkDZR4be

Arma2MySql Log: http://pastebin.com/Er4jm26N

RPT File: http://pastebin.com/M0fy63J6

##### Share on other sites

It looks like it's line 160 of the RPT file. Here, tsc is being set to "any" when it should be getting an actual value. When the plugin tries to send this to the database, it fails. It's looking for an integer value. You'll have to fix the SQF script wherever it's creating the query.

##### Share on other sites

Is there any indication of where this can be fixed? I've looked through all the PDB files and only found one with tsc contained in it and I don't see what the issue is or if there is what I should change.

##### Share on other sites

I'm not sure. [KH]JMan and others who were working on this project have stopped and moved to MSO. You may want to try that mission/system instead.

##### Share on other sites

@Holmes

The legacy standalone version of pdb that you are trying to use contains many bugs/issues one of which relates to the tsc = any issue. The code fix will be in the mso dev git branch but will more than likely be reliant on other changes that were made in that branch. When A2 1.62 final patch is released we will be releasing the final version of A2 mso which will contain all the pdb fixes and after that if I have time I might update the standalone version. If you cannot wait and know Sqf/dB I would suggest that you pull back the mso dev git branch and try to refractor the legacy base code from it.

##### Share on other sites

When I start the given "Co18_PDB_ConvoyHell_v1-5-100.Takistan.pbo" mission it tells me that I was successfully added to the database but when I check the DB the tables are all empty.

Now I tried another missions and all it does is flooding the server console saying "Mission XYZ read from bank." when the first player connects until he disconnects.

Does anybody have an idea? I added the Database.txt to the Arma OA root folder and to the folder in AppData but it is not working.

##### Share on other sites
=====================================================================
=====================================================================
Exe timestamp: 2013/05/10 00:41:16
Current time:  2013/05/20 16:51:56

Version 1.62.103419
2013/05/20, 16:51:56 Warning Message: mpmissions\__cur_mp.Takistan\mission.sqm/Mission/Groups/Item0/Vehicles/Item0.vehicle: Vehicle class USMC_Soldier no longer exists
2013/05/20, 16:51:56 Type USMC_Soldier is not VehicleType
2013/05/20, 16:51:57 Server error: Player without identity Armitxes (id XXXXXXXX)
2013/05/20, 16:52:18 Vehicle type USMC_Soldier does not exist

##### Share on other sites

So many things Im confused about getting this set up is... Well A lot...

Completely lost how to get it work with MSO, I mean where am I suppose to install the MySQL etc etc...

##### Share on other sites
So many things Im confused about getting this set up is... Well A lot...

Completely lost how to get it work with MSO, I mean where am I suppose to install the MySQL etc etc...

You would need a website host which has a MYSQL available. That way you could host the necessary database needed.

##### Share on other sites

Like R0adki11 said your server host would need to allow you to install mySQL and configure it properly. If you have full desktop access to your server (ie: RDP or VNC), this is easy as you can do it yourself. You also need to know a bit about mySQL and how to install a schema and be able to truncate tables when needed (ie: wipe the DB).

The instructions from the MSO download are pretty good it walks you through the steps. Make sure the 'arma' user has full rights on the DB and that you have your .txt file with DB password in the correct location. The MSO guys are very helpful and they have a Skype channel you can join where they will attempt to help you out.

##### Share on other sites

I know how to get the MySQL working, worked with it on one multiplayer game that used gamemodes and had mysql.

Only problem is, a host that allows mysql connections, either free and paid...

##### Share on other sites

Is there a way to make a client side database so people cant steal your database from the server side mission file?

If so what do i need to do in order to accomplish this and how hard is it?

##### Share on other sites

Hey Guys,

my Problem is

Info: 23:28:00 - Received - Database: arma Procedure: UpdatePlayer Parameters: tsc=0,tpos=8035.55|1941.26|0.00143433,tdam=0,tdhe=0,tdbo=0,tdha=0,tdle=0,tdir=0,tsta=Stand,tsid=WEST,tveh=any,tsea=,ttyp=US_Soldier_TL_EP1,trat=3500,tvd=1600,ttd=0,tran=CAPTAIN,tfir=0,tek=0,tck=0,tfk=0,tsui=0,tlif=ALIVE,tdea=0,ttp=329.404,tlc="24.06.2013 21:22:31",tld="24.06.2013 21:28:00",tpid=3224642,tna=[101st.AD] Momby,tmid=<null>
Info: 23:28:00 - Parsing parameters...
Warning: 23:28:00 - MySQL error. MySql.Data.MySqlClient.MySqlException (0x80004005): Incorrect integer value: '<null>' for column 'tmid' at row 1
bei MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
bei MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
bei MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
bei Arma2NETMySQLPlugin.MySQL.RunOnDatabase(MySqlCommand command, Int32 maxResultSize)
Info: 23:28:00 - Parsing parameters...
Warning: 23:28:00 - MySQL error. MySql.Data.MySqlClient.MySqlException (0x80004005): Incorrect integer value: '<null>' for column 'tmid' at row 1
bei MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
bei MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
bei MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
bei Arma2NETMySQLPlugin.MySQL.RunOnDatabase(MySqlCommand command, Int32 maxResultSize)
Info: 23:30:22 - Received - Database: arma Procedure: UpdateDate Parameters: tda=2012|7|2|11|37,tmid=<null>
Info: 23:30:22 - Parsing parameters...
Warning: 23:30:22 - MySQL error. MySql.Data.MySqlClient.MySqlException (0x80004005): Incorrect integer value: '<null>' for column 'tmid' at row 1
bei MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
bei MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
bei MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
bei Arma2NETMySQLPlugin.MySQL.RunOnDatabase(MySqlCommand command, Int32 maxResultSize)

06/24/2013 23:28:00 function: DateTime ['utcnow',]
06/24/2013 23:28:00 maxResultSize: 4095
06/24/2013 23:28:00 Result size: 21
06/24/2013 23:28:00 Result: "24.06.2013 21:28:00"
06/24/2013 23:28:00 function: Arma2NETMySQL ['arma','UpdatePlayer','tsc=0,tpos=8035.55|1941.26|0.00143433,tdam=0,tdhe=0,tdbo=0,tdha=0,tdle=0,tdir=0,tsta=Stand,tsid=WEST,tveh=any,tsea=,ttyp=US_Soldier_TL_EP1,trat=3500,tvd=1600,ttd=0,tran=CAPTAIN,tfir=0,tek=0,tck=0,tfk=0,tsui=0,tlif=ALIVE,tdea=0,ttp=329.404,tlc="24.06.2013 21:22:31",tld="24.06.2013 21:28:00",tpid=3224642,tna=[101st.AD] Momby,tmid=<null>']
06/24/2013 23:28:00 maxResultSize: 4095
06/24/2013 23:28:00 Result size: 13
06/24/2013 23:28:00 Result: [[["Error"]]]
06/24/2013 23:28:00 maxResultSize: 4095
06/24/2013 23:28:00 Result size: 13
06/24/2013 23:28:00 Result: [[["Error"]]]
06/24/2013 23:30:22 function: Arma2NETMySQL ['arma','UpdateDate','[tda=2012|7|2|11|37,tmid=<null>]']
06/24/2013 23:30:22 maxResultSize: 4095
06/24/2013 23:30:22 Result size: 13
06/24/2013 23:30:22 Result: [[["Error"]]]

I've connected my Arma 2 to the Database but i've got this error message ........ "tmid = null"

could someone give me a solution of my problem!?