Jump to content
Sign in to follow this  
firefly2442

Arma2MySQL

Recommended Posts

Do MySQL and MySQL connector need to be installed to the same directory or doesn't it matter?

It doesn't make any difference.

Edited by Polaris

Share this post


Link to post
Share on other sites

By adding this to init.sqf i've got the ArmA2Net log to report:

"Arma2Net.Unmanaged" callExtension "Activate Arma2NETMySQL";
"Arma2Net.Unmanaged" callExtension "Activate Arma2NETMySQLCommand";

07/23/2012 17:07:01 Log: Unmanaged side loaded
07/23/2012 17:07:01 Info Successfully loaded into process arma2oaserver
07/23/2012 17:07:01 Info Arma2NET 1.13.0.0 initializing on CLR 4.0.30319.269
07/23/2012 17:07:01 Info Sandboxing is disabled
07/23/2012 17:07:01 Info Rebuilding addin store
07/23/2012 17:07:01 Info Finding addins
07/23/2012 17:07:01 Info Found addins: Activate, IsFunction, Deactivate, _Empty, VersionOfAddIn, CompareVersion, ClrVersion, Version, Functions, CommandLine, DateTime, Arma2NETMySQL, Arma2NETMySQLCommand
07/23/2012 17:07:01 Info Activating base addins
07/23/2012 17:07:01 Info Activated Activate from BaseFunctionsPlugin.Activate, BaseFunctionsPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8762987cc8e6095e (Sandboxed: False)
07/23/2012 17:07:01 Info Activated IsFunction from BaseFunctionsPlugin.IsFunction, BaseFunctionsPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8762987cc8e6095e (Sandboxed: False)
07/23/2012 17:07:01 Info Activated Deactivate from BaseFunctionsPlugin.Deactivate, BaseFunctionsPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8762987cc8e6095e (Sandboxed: False)
07/23/2012 17:07:01 Info Activated _Empty from BaseFunctionsPlugin._Empty, BaseFunctionsPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8762987cc8e6095e (Sandboxed: False)
07/23/2012 17:07:01 Info Activated VersionOfAddIn from BaseFunctionsPlugin.VersionOfAddIn, BaseFunctionsPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8762987cc8e6095e (Sandboxed: False)
07/23/2012 17:07:01 Info Activated CompareVersion from BaseFunctionsPlugin.CompareVersion, BaseFunctionsPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8762987cc8e6095e (Sandboxed: False)
07/23/2012 17:07:01 Info Activated ClrVersion from BaseFunctionsPlugin.ClrVersion, BaseFunctionsPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8762987cc8e6095e (Sandboxed: False)
07/23/2012 17:07:01 Info Activated Version from BaseFunctionsPlugin.Arma2NetVersion, BaseFunctionsPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8762987cc8e6095e (Sandboxed: False)
07/23/2012 17:07:01 Info Activated Functions from BaseFunctionsPlugin.Functions, BaseFunctionsPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8762987cc8e6095e (Sandboxed: False)
07/23/2012 17:07:01 Info Arma2NET initialized
07/23/2012 17:07:01 Info Activated Arma2NETMySQL from Arma2NETMySQLPlugin.Arma2NETMySQLPlugin, Arma2NETMySQLPlugin, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null (Sandboxed: False)
07/23/2012 17:07:01 Info Activated Arma2NETMySQLCommand from Arma2NETMySQLPlugin.Arma2NETMySQLPluginCommand, Arma2NETMySQLPlugin, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null (Sandboxed: False)

However the plugin log still isn't being created and 'any' value is still being returned in the script.

Share this post


Link to post
Share on other sites

Hi,

I managed to store some value in my database ( position of the player as : x, y, z. Those 3 value are stored as int)

but when i trie to get them from the database

Everything is working except that the value are like that : [[["1542"]]] , ["1554"]]] , [[["0"]]]

and i cant use them as numbers in arma 2

what am i missing to be able to use those stored values as variable in sqf scritps ?

------EDIT--------

I managed to make the things works but:

the result of : _x = "Arma2Net.Unmanaged" callExtension "Arma2NETMySQLCommand ['test', 'SELECT x FROM position WHERE player=guigui']";

is a 3d array so i had to make some ugly code :

_x = "Arma2Net.Unmanaged" callExtension "Arma2NETMySQLCommand ['test', 'SELECT x FROM position WHERE player=guigui']";

_y = "Arma2Net.Unmanaged" callExtension "Arma2NETMySQLCommand ['test', 'SELECT y FROM position WHERE player=guigui']";

_z = "Arma2Net.Unmanaged" callExtension "Arma2NETMySQLCommand ['test', 'SELECT z FROM position WHERE player=guigui']";

_x = call compile _x;

_y = call compile _y;

_z = call compile _z;

_x = _x select 0 select 0 select 0 ;

_y = _y select 0 select 0 select 0;

_z = _z select 0 select 0 select 0;

_x = parseNumber _x;

_y = parseNumber _y;

_z = parseNumber _z;

to be able to use my data in :

player setPos[ _x, _Y, _Z];

how can i get rid of those 9 lines ?

sorry for my poor english ^^

Edited by Guillaume

Share this post


Link to post
Share on other sites

Can you post compiled versions to be safe please firefly?

As far as I can tell it simply doesn't recognise the commands when used in the script. They work in arma2netexplorer and in mysql. ArmA2Net and the plugin are activated according to the ArmA2Net log. It's just the command doesn't seem to call the plugin, no plugin log is created in /logs and 'any' is returned in game.

Edit: The command works ONLY if it's in init.sqf, nowhere else? WTF?

Edited by Polaris

Share this post


Link to post
Share on other sites

@Guillaume - Ahh, I think I can fix this on the plugin side. I'll look at it.

@Polaris - Yep, I'll do that tonight when I get home.

Share this post


Link to post
Share on other sites

Awesome, thank you firefly, I appreciate it.

Do you know why commands only work in init.sqf? The exact same command in init.sqf and whatever.sqf will work in init but not in whatever.

Share this post


Link to post
Share on other sites

AFAIK, init is called automatically at the beginning of the mission. You'll need to include or call the whatever.sqf code in init.

Share this post


Link to post
Share on other sites

I was doing that, it just seems to only be working if it's in the init directly?

Plus how exactly are you meant to get a result that you can actually use? If I try and use it I get all kinds of errors.

Also how do you insert variables into raw MySQL commands?

Edited by Polaris

Share this post


Link to post
Share on other sites

@Polaris - Use select like Guillaume was using. To insert variables, you'll have to create the string by concatenating values together. Like so:

_strCreate = format ["[u=%1,n=%2,a=%3,b=%4,c=%5,d=%6,e=%7]", _allWeapons select 0, _loadoutName, _allWeapons select 1,
														_allWeapons select 2, _allWeapons select 3, 
														_allWeapons select 4, _allWeapons select 5];

https://community.bistudio.com/wiki/format

@Polaris and Guillaume - Please try this:

https://dev-heaven.net/issues/37914

No promises that it will work. Hopefully everyone enjoys being a beta tester. :)

Share this post


Link to post
Share on other sites

Thank you firefly, I worked that out by using stored procedures, I couldn't get it to work with raw MySQL though. Is it even possible with raw MySQL? I've got inserting data working I just can't seem to get read data into a useable format. I understand that it's stored as an array and that select 0...1...2...etc selects the variable you want in the array however as you can see below, I am selecting the only one but in-game the hint is 'any' and I just can't get it to say anything else. The MySQL side of it works it's just once it's read the data I can't get it into a useable format within the sqf.

_uid = "1911238";

_parameters = format["[uid=%1]",_uid];

_insert = "Arma2Net.Unmanaged" callExtension format ["Arma2NETMySQL ['lifeprojectrpg', 'ReadTest', '%1']", _parameters];

_insert = call compile _insert;

_x = _insert select 0;

hint format["%1",_x];

Do I have to put 3 select 0s?

This is the procedure it's calling:

DELIMITER $$

CREATE DEFINER=`polaris`@`localhost` PROCEDURE `ReadTest`(IN uid INTEGER(11))
BEGIN
SELECT na from players where pid=uid;
END

The hint in game comes up as 'any' :(. I've tried your version and it still says 'any' :(.

I've been trying now for hours and I can't get anything but 'any' to return in game! It's honestly driving me crazy, I'm so close to being able to actually get on and create scripts :p.

Edited by Polaris

Share this post


Link to post
Share on other sites

Try this:

hint ("Arma2Net.Unmanaged" callExtension format ["Arma2NETMySQL ['lifeprojectrpg', 'ReadTest', '%1']", _parameters]);

Share this post


Link to post
Share on other sites

Ok here is another probleme i cant resolve

I have an array with 193 things in it ( allUnits Command returned result of the 193 units on the map)

when i trigger my save script i have 3 possible result :

- it works and my array is stored in the database as a LONGTEXT

- i have an error in the log : Error: 11:13:41 - The number and/or format of the arguments passed in doesn't match.

- or i have this error :

Warning: 11:13:05 - MySQL error. MySql.Data.MySqlClient.MySqlException (0x80004005): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '["1Rnd_HE_M203","1Rnd_HE_M203","1Rnd_HE_M203","1Rnd_HE_M203","1Rnd_HE_M203","1Rn' at line 1

à MySql.Data.MySqlClient.MySqlStream.ReadPacket()

à MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int32& insertedId)

à MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int32& insertedId)

à MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)

à MySql.Data.MySqlClient.MySqlDataReader.NextResult()

à MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)

à MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()

à Arma2NETMySQLPlugin.MySQL.RunOnDatabase(MySqlCommand command, Int32 maxResultSize)

It's like russian roulette.

I didn't change anything just triggering the save script several times.


//save.sqf

//from addaction 

position = getPos p1;
_currentWeapon = currentweapon p1;
_currentmags = magazines p1;
_obj = allUnits;
hint format["Units count :%1",count(_obj)];
//save position
"Arma2Net.Unmanaged" callExtension format["Arma2NETMySQLCommand ['test', 'UPDATE position SET x=%1,y=%2,z=%3,weapon='%4',chargeurs='%5' WHERE player ='guigui'']", round(position select 0),round(position select 1),round(position select 2),_currentWeapon,_currentmags];
"Arma2Net.Unmanaged" callExtension format["Arma2NETMySQLCommand ['test', 'INSERT INTO object (objets) VALUES ('%1')']",_obj];

here is the log file : http://pastebin.com/se7CV4g7

EDIT ---------------------

Also how can i manage to store an array of array as a string :

  Civil_ = [["","Civil_","","Civil","Civil_","jtyjtyjty","jtyjtyjtyjtyjty","18","grgdrgrdgdgdrgdrg"],[1.94325e+006,"7822"],["voiture","camion","arme"],["X179TB80","A657DX3","D174NR27","I322GC80","X847NE74","X135OW9","W143VG73","I192MG64","E807OC1","W25RO99","Y738YG69","L374FW11","L180DG3","D950HO93","I79JP22"],["diplome_distillerie","diplome_commercial","diplome_agriculture","diplome_pompier"],[0,0,0,602,0,0,0,9404,0,0,0,0,0,9900,9940,9910],[13,4,25,26,88,88,88,88,88,12,100,0,0],["Civil_Homme45","Tete1","Identiter_Base"],[]] ;publicvariable "Civil_";

I aldready tried :

 
"Arma2Net.Unmanaged" callExtension format["Arma2NETMySQLCommand ['test', 'UPDATE civil SET sauvegarde='%1' WHERE player ='guigui'']",Civil_]; 
//or
civil_format = format ["%1",Civil_];
"Arma2Net.Unmanaged" callExtension format["Arma2NETMySQLCommand ['test', 'UPDATE civil SET sauvegarde='%1' WHERE player ='guigui'']",civil_format ];

I got that error :The number and/or format of the arguments passed in doesn't match.

Edited by Guillaume

Share this post


Link to post
Share on other sites

All the stored procedure stuff should be the same for raw sql commands. I like the stored procedures because it seems a little easier to use and understand once you have the stored procedures written. But it's all up to you.

Hmm, I'm not quite sure about the overall sqf formatting. My SQF coding skills are rudimentary at best. I can help with the plugin or the database structure but other than that, I'm afraid someone else may need to chime in.

Share this post


Link to post
Share on other sites

Alright, I'm actually finding procedures a little easier in terms of code organisation, plus you can edit the MySQL much more easily in something like workbench rather than trawling through the scripts.

Ok, I'll possibly ask Jman in that case, he seems to know the SQL side quite well.

Share this post


Link to post
Share on other sites

We (JMan, Scott, ArmaTec, Kju, Tupolov, and others) have a Skype group as well for testing and such. It's more for development work but if you're interested I can add you (PM me your Skype username). That might be better than just spamming the forums over and over. :D

Share this post


Link to post
Share on other sites

I made some progress this weekend on the example mission. The dialog system is getting populated correctly (and I think I'm starting to understand the structure more). I'm still working on saving and setting the weapon loadouts though.

Share this post


Link to post
Share on other sites

Sqlite support has been added in the sqlite branch. Once that's tested and considered stable I'll merge it into the master branch.

Share this post


Link to post
Share on other sites

Hi Firefly,

thanks for your extension. I apologize if this has been asked before but I didnt went through the 140+ forum pages and search did not return anything useful.

Now to my issue: As I understand the current alternative DayZ hive builds rely on arma2net and your library to update data in a central database. However we are experiencing significant performance drops after 2+ hours of gameplay with 20+ users.

The client FPS get lower and the login/joining procedure (which is one of the things that runs DB queries through your plugin) take minutes instead of seconds.

As we analyzed that server load/mysql performance is not the issue here. So I believe the issue lies in Arma2Net or in your plugin - somehow the queries get significantly slower over time - leading to this behaviour.

However I currently have no idea how to further isolate/troubleshoot this problem. Do you think of any circumstances leading to this behaviour which could be caused by your plugin? Are there any extended logging options one could activate to see possible delays etc?

Thanks!

Share this post


Link to post
Share on other sites
Hi Firefly,

Now to my issue: As I understand the current alternative DayZ hive builds rely on arma2net and your library to update data in a central database. However we are experiencing significant performance drops after 2+ hours of gameplay with 20+ users.

The client FPS get lower and the login/joining procedure (which is one of the things that runs DB queries through your plugin) take minutes instead of seconds.

Incorrect. DayZ used to use jayarma2lib. Now it uses nothing, just its own DLL using the callExtension command. So any issue is with HiveEXT and has nothing to do at all with Arma2net.

  • Like 2

Share this post


Link to post
Share on other sites

Hi Rocket,

I was not talking about the official hive but as I wrote about alternative hive builds which do rely on Arma2Lib.

thanks

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×