Jump to content
Sign in to follow this  
firefly2442

Arma2MySQL

Recommended Posts

_dbloadouts = call compile _dbloadouts;

This actually converts the string to an array.

Since you have the value encapsulated in three arrays (I'm not sure why it's three, you may want to look into that...). You should be able to just use "select 0" down to the specific value. Perhaps you have one extra select in there?

Okey, I tried doing it better this time, but returns this. Printed it.

From Log

21:14:20 "_dbloadouts = call compile _dbloadouts; Returns: [[["55556"]]]"
21:14:20 "_dbloadouts = _dbloadouts select 0; Returns: [["55556"]]"

_uid = _this select 0;
_query = format ["SELECT test FROM users WHERE uid = '%1'", _uid];
_dbloadouts = "Arma2Net.Unmanaged" callExtension format ["Arma2NETMySQLCommand ['life', '%1']", _query];
_dbloadouts = call compile _dbloadouts;
diag_log format ["_dbloadouts = call compile _dbloadouts; Returns: %1", _dbloadouts];
_dbloadouts = _dbloadouts select 0; 
diag_log format ["_dbloadouts = _dbloadouts select 0; Returns: %1", _dbloadouts];
Ammount = _dbloadouts;

When I had this in there it removed [[""]] from the log.

_myValue = (_dbloadouts select 0) select 0;
_myValue = _myValue select 0;

Edited by Staffan

Share this post


Link to post
Share on other sites

Does this work?

_uid = _this select 0;
_query = format ["SELECT test FROM users WHERE uid = '%1'", _uid];
_dbloadouts = "Arma2Net.Unmanaged" callExtension format ["Arma2NETMySQLCommand ['life', '%1']", _query];
_dbloadouts = call compile _dbloadouts;
diag_log format ["_dbloadouts = call compile _dbloadouts; Returns: %1", _dbloadouts];
_dbloadouts = _dbloadouts select 0;
_dbloadouts = _dbloadouts select 0;
_dbloadouts = _dbloadouts select 0;
diag_log format ["_dbloadouts final value: %1", _dbloadouts];
Ammount = _dbloadouts;

Share this post


Link to post
Share on other sites
Does this work?

_uid = _this select 0;
_query = format ["SELECT test FROM users WHERE uid = '%1'", _uid];
_dbloadouts = "Arma2Net.Unmanaged" callExtension format ["Arma2NETMySQLCommand ['life', '%1']", _query];
_dbloadouts = call compile _dbloadouts;
diag_log format ["_dbloadouts = call compile _dbloadouts; Returns: %1", _dbloadouts];
_dbloadouts = _dbloadouts select 0;
_dbloadouts = _dbloadouts select 0;
_dbloadouts = _dbloadouts select 0;
diag_log format ["_dbloadouts final value: %1", _dbloadouts];
Ammount = _dbloadouts;

Hi Firefly,

Sorry for answering late, been traveling the past few days. Just tried it out, some how it's still not returning I have no clue why and how I can fix it.

I still get "any" in the variable array. But it returns it" _dbloadouts final value: 55556" It removed everything like before.

Ammount = _dbloadouts; returns to "any" have no clue why or how to fix it, I tried as well to see if the scripts is blocking it in server_events.sqf so I just placed Ammount = 500; and that worked perfect, but when I load it from the database it just says "any" nothing else.

I'm out of ideas, don't know about you, you have some tweeks for me?

Share this post


Link to post
Share on other sites

Hmm, I'm not sure. You may want to start a new thread and ask. The plugin and your code is working correctly because the _dbloadouts variable has the correct value. It must be some sort of variable type issue.

Share this post


Link to post
Share on other sites

I believe i got this to work with Arma 3, but i need an example mission or a Wasteland mission with all of the necessary .sqf's. I could start trying to write one of own but i know someone must have one working already they would like to share, and im not 100% positive this is working as i have not seen it in the game in action. I do have my "arma" database in navicat, and im pretty sure i have the Database.txt set up correctly. I am positive i have everything else set up as i followed the guide on page 9 of this forum. If you would like to help me, please message me. It has been a long day learning all these new things to get this far... time to just play some wastelands. Thank you.

*Edit*

I forgot to mention, I did try some of the Example files and copied them to my Wasteland script, but im not sure if the option for "Random" selection collides with the DB as its different from Dayz's random spawn (yet more like origins)

Share this post


Link to post
Share on other sites

when i try to run this on the dedicated server batch file, it tells me that the script_macros is missing from the CBA addon and wont start. I can run it just fine on Arma 3, but i'm not sure if i can test its functionality that way. When i run it by itself, i can go up to the box and use the loadout screen but the box is black and none of the functions are working for me.

*Edit*

Here is exactly what it says in the error box:

Include file x\cba\addons\main\script_macros.hpp not found.

Edited by Nebulazer

Share this post


Link to post
Share on other sites

So, there are two different example missions. One for Arma3 and one for Arma2. Which version of Arma are you trying to create a mission for?

CBA is required for both examples. A development version of CBA has been posted for Arma3 and of course, CBA is widely used in Arma2.

Share this post


Link to post
Share on other sites
So, there are two different example missions. One for Arma3 and one for Arma2. Which version of Arma are you trying to create a mission for?

CBA is required for both examples. A development version of CBA has been posted for Arma3 and of course, CBA is widely used in Arma2.

As mentioned before, i am doing this for Arma 3. I downloaded the CBA here http://www.armaholic.com/page.php?id=18767 and i am certain i have installed everything properly. What is that Script_macros.hpp its asking for?

*edit* i just tried using Play withSIX downloader to get CBA but i still got the same error. I think it might be the ARMA3SERVERWASTELANDAUTO batch file i am using, but i have extensively looked through the setting on that to make sure it was all changed to work with that mission. I even get up to the "waiting for host" part of it. Is it because I am trying to run 2 instances of Arma on my computer (one as the small server text box)? Also, i can see that CBA is running because it has its Logo on the Arma 3 Home Menu. Im pretty confused. Maybe a demo without any addons? Something that will work with Wasteland (as we all know thats what we want this for). Thank You :)

Edited by Nebulazer

Share this post


Link to post
Share on other sites

You can take CBA out if you wish. CBA is required for the event handler system. If you look in the readme, you will find details about how to call the plugin and pass information back and forth. I don't play wasteland so I won't be porting any database functionality over to it.

Perhaps something changed in the Alpha, let me test it when I get home to see if there is an issue with CBA.

Share this post


Link to post
Share on other sites

ok. so would i have to make a new folder in mission file that would be like save.sqf, load.sqf init.sqf and then an execVM in the init or is it going to be a call compile? I am a little confused between the 2, all though i do know a call compile will run it continuously and an exec only runs it once. I had a little bit of trouble trying to get iniDB running with this though, it kept telling me it couldnt find the \iniDB\init.sqf allthough i know it was in the right place unless it wasnt supposed to go in the mission file at all. Any guidance with this will be much appreciated. Thank you.

Share this post


Link to post
Share on other sites
I was not able to replicate the problem you are having with CBA.

This is because i think it has something to do with the Server.bat file i am using. I might have to wait for an official server.bat to come out or if you have one that you know works with this maybe you can help me out. I should be getting my new Vilayer server sometime tonight, but they sent me an email saying it was postponed because BI was releasing a new Dedi Server Software for them to use. Maybe DB included because of mister Dean Hall. Fingers Crossed. I would still like to have this working to know that i got it working and because i will still be using this computer as a test server.

Share this post


Link to post
Share on other sites

Firefly, your repo's are 404'ing. Have you discontinued working on this project?

Share this post


Link to post
Share on other sites
Firefly, your repo's are 404'ing. Have you discontinued working on this project?

edit: It's back up. Thanks Github support. :)

Edited by firefly2442

Share this post


Link to post
Share on other sites
edit: It's back up. Thanks Github support. :)

Just noticed that - thanks!

EDIT: More or less got it working now I have found your A3 demo mission.

Edited by shinkicker

Share this post


Link to post
Share on other sites
Just noticed that - thanks!

I wanted to ask you a quick couple of Q's:

I have @Arma2NET in the root of my Arma 3 installation. -mod=@Arma2NET

Mysql is running and the ODBC connector is installed.

I now have Arma2NETMySQLPlugin_Alpha_v0_02.zip

It looks like I need to unarchive the DLL into @Arma2NET\AddIns - but do I need to provide a certain folder name, or does Arma2NET scan all the folders in there for plugins regardless of the folder names?

for example @Arma2NET\AddIns\Arma2NETMySQLPlugin

I am also not seeing Arma2NET log anything at all to my RPT so it might well be underlying causes here.

That's actually a slightly older version. I updated the zip file on dropbox:

https://www.dropbox.com/sh/ngix8aunt9nnwj7/ZHt1agEeM0

It requires a very specific folder structure which is documented in the readme. Also, checkout the video (slightly old) on the top of the dropbox page. It has instructions for Arma 2 but it should all be the same for Arma 3.

Share this post


Link to post
Share on other sites
I updated the zip file on dropbox.

Many Thanks!

I can see the following shown in the readme:

E:\Program Files\Steam\steamapps\common\arma 2 operation arrowhead\@Arma2NET\AddIns\Arma2NETMySQLPlugin\MySql.Data.dll

Is this still needed or did you merge code into the main DLL? There is no MySql.Data.dll in any of the folders.

Here is what I see so far (using the arma 3 example mission):

Info: 12:53:19 - Logging started in directory: C:\Program Files (x86)\Steam\steamapps\common\Arma 3\logs\
Info: 12:53:19 - Arma2NETMySQL Plugin Started.
Info: 12:53:19 - Version number: 0.1.0.0
Info: 12:53:19 - Loading databases...
Info: 12:53:19 - Databases.txt file loading in from: C:\Program Files (x86)\Steam\steamapps\common\Arma 3\Databases.txt
Info: 12:53:19 - Type: mysql Database: weaponsarma3 IPAddress: 127.0.0.1 Port: 3306 Username: arma Password: NotShownForSecurityReasons

Error in expression <throw "System.Reflection.TargetInvocatio>
 Error position: <throw "System.Reflection.TargetInvocatio>
 Error 
[73961,2833.75,11.785,"mpmissions\__cur_mp.Stratis\as_loadouts\getLoadouts.sqf:4","EXPLODE_1 _this: _unit=player1"]
[73961,2833.75,11.785,"mpmissions\__cur_mp.Stratis\as_loadouts\server_events.sqf:61","Query: : _query=SELECT name FROM users WHERE uid = '76561198073149386'"]

My setup:

DB is working ok

MGyRSKh.png

Folder structure:

vokuqbn.png

Databases.txt

mysql,weaponsarma3,127.0.0.1,3306,arma,123

Launch Parameters:

"C:\Program Files (x86)\Steam\steamapps\common\Arma 3\arma3.exe" -nosplash -nopause -mod=@Arma2NET;@CBA_A3

Ingame shot

j2OfXxG.png

Edited by shinkicker

Share this post


Link to post
Share on other sites

I can see the following shown in the readme:

E:\Program Files\Steam\steamapps\common\arma 2 operation arrowhead\@Arma2NET\AddIns\Arma2NETMySQLPlugin\MySql.Data.dll

Is this still needed or did you merge code into the main DLL? There is no MySql.Data.dll in any of the folders.

Ahh sorry, I will fix that, it's incorrect. The main plugin .dll is required: "Arma2NETMySQLPlugin.dll" and needs to be in that folder. The other two are the dependencies that you install. These are the MySQL connector and SQLite bundle (again see readme for links). You need to install these otherwise it won't work. It may (I'm not sure) require the exact version that I used to compile it with (again you can see in the readme) for these two dependencies.

Share this post


Link to post
Share on other sites
The other two are the dependencies that you install. These are the MySQL connector and SQLite bundle (again see readme for links).

I have the connector installed, but its not supplied as a DLL named 'Mysql.Data.DLL' its an MSI installer which has a destination of:

C:\Program Files\MySQL\Connector ODBC 5.2

wAunYkv.png

I used the source to build again with all the needed references added. I now see:

Info: 20:28:06 - Logging started in directory: C:\Program Files (x86)\Steam\steamapps\common\Arma 3\logs\
Info: 20:28:06 - Arma2NETMySQL Plugin Started.
Info: 20:28:06 - Version number: 0.1.0.0
Info: 20:28:06 - Loading databases...
Info: 20:28:06 - Databases.txt file loading in from: C:\Program Files (x86)\Steam\steamapps\common\Arma 3\Databases.txt
Info: 20:28:06 - Type: mysql Database: weaponsarma3 IPAddress: 127.0.0.1 Port: 3306 Username: arma Password: NotShownForSecurityReasons
Info: 20:28:07 - Received - Database: weaponsArma3 SQL Query: SELECT name FROM users WHERE uid = '76561198073149386'
Warning: 20:28:07 - The database: weaponsArma3 is not loaded in through the Databases.txt file.

Which is from the following code:

 if (SQL.dbs.SQLProviderExists(database))
               {
                   IEnumerable<string[][]> returned = SQL.dbs.getSQLProvider(database).RunCommand(mysql_command, maxResultSize);
                   return Format.ObjectAsSqf(returned);
               }
               else
               {
                   Logger.addMessage(Logger.LogType.Warning, "The database: " + database + " is not loaded in through the Databases.txt file.");
               }

So is the issue that the Database.txt is not found?

I have it in C:\Users\<user>\AppData\Local\Arma2NETMySQL and the root of Arma 3

Edited by shinkicker

Share this post


Link to post
Share on other sites

The Databases.txt file only needs to be in one of those two places. As you can see in the log file, it's using the root Arma 3 directory first. What's the error now?

Share this post


Link to post
Share on other sites

Sorry, totally worded that wrong. My database.txt is present, but I am wondering if its being parsed correctly;

# This is a comment
# Any line starting with a "#" is considered a comment
# Make sure each of your database connections doesn't have a "#" in front!
# Put each database connection you want on a separate line
# The databasename MUST be unique!
# For an example, see the following
#databasetype,databasename,ipaddress,port,username,password
#
#mysql,arma,127.0.0.1,3306,armausername,secret
#sqlite,weaponslite

mysql,weaponsarma3,127.0.0.1,3306,arma,123

This is the current error:

Error in expression <s;



_dbloadoutnames = _dbloadoutnames select 0;



{ _loadouts set [count _loa>
 Error position: <select 0;



{ _loadouts set [count _loa>
 Error select: Type Bool, expected Array,Config entry
File mpmissions\__cur_mp.Stratis\as_loadouts\getLoadouts.sqf, line 42
[3432,111.069,15.679,"mpmissions\__cur_mp.Stratis\as_loadouts\getLoadouts.sqf:4","EXPLODE_1 _this: _unit=player1"]
[3432,111.069,15.679,"mpmissions\__cur_mp.Stratis\as_loadouts\server_events.sqf:61","Query: : _query=SELECT name FROM users WHERE uid = '76561198073149386'"]
Ref to nonnetwork object Agent 0x43db6040

From what I can see that would because I don't have a current entry in USERS yet, would need first to do a 'INSERT INTO USERS...' first?

Share this post


Link to post
Share on other sites

Did you use the provided .sql file to setup the database structure first?

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  

×