Skip to content

Commit

Permalink
plugin now builds for Arma2NET version 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
firefly2442 committed Jul 21, 2012
1 parent ad6cf60 commit b61b777
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 26 deletions.
19 changes: 9 additions & 10 deletions Arma2NETMySQLPlugin/Arma2NETMySQLPlugin.cs
Expand Up @@ -3,19 +3,18 @@
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.AddIn;
using AddInView;
using Arma2Net.Managed;
using Arma2Net.AddInProxy;

namespace Arma2NETMySQLPlugin
{
//the function name for the plugin (called from Arma side)
[AddIn("Arma2NETMySQL", Version = "0.1.0.0", Publisher = "firefly2442", Description = "Runs MySQL procedure commands.")]
public class Arma2NETMySQLPlugin : Arma2NetLongOutputAddIn
public class Arma2NETMySQLPlugin : AddIn
{
//This method is called when callExtension is used from SQF:
//"Arma2Net.Unmanaged" callExtension "Arma2NetMySQL ..."
public override string Run(string args, int maxResultSize)
public override string Invoke(string args, int maxResultSize)
{
//if we haven't setup the database connection and such yet, this will do it
Startup.StartupConnection();
Expand All @@ -42,15 +41,15 @@ public override string Run(string args, int maxResultSize)
if (MySQL.dbs.SQLProviderExists(database))
{
IEnumerable<string[][]> returned = MySQL.dbs.getSQLProvider(database).RunProcedure(procedure, split.ToArray(), maxResultSize);
return Arma2Net.Managed.Format.ObjectAsSqf(returned);
return Format.ObjectAsSqf(returned);
}
else
{
Logger.addMessage(Logger.LogType.Warning, "The database: " + database + " is not loaded in through the Databases.txt file.");
}

//Logger.addMessage(Logger.LogType.Info, "Returning false object");
return Arma2Net.Managed.Format.ObjectAsSqf(false);
return Format.ObjectAsSqf(false);
}
else
{
Expand All @@ -62,11 +61,11 @@ public override string Run(string args, int maxResultSize)

//the function name for the plugin (called from Arma side)
[AddIn("Arma2NETMySQLCommand", Version = "0.1.0.0", Publisher = "firefly2442", Description = "Runs raw MySQL commands")]
public class Arma2NETMySQLPluginCommand : Arma2NetLongOutputAddIn
public class Arma2NETMySQLPluginCommand : AddIn
{
//This method is called when callExtension is used from SQF:
//"Arma2Net.Unmanaged" callExtension "Arma2NetMySQLCommand ..."
public override string Run(string args, int maxResultSize)
public override string Invoke(string args, int maxResultSize)
{
//if we haven't setup the database connection and such yet, this will do it
Startup.StartupConnection();
Expand All @@ -82,15 +81,15 @@ public override string Run(string args, int maxResultSize)
if (MySQL.dbs.SQLProviderExists(database))
{
IEnumerable<string[][]> returned = MySQL.dbs.getSQLProvider(database).RunCommand(mysql_command, maxResultSize);
return Arma2Net.Managed.Format.ObjectAsSqf(returned);
return Format.ObjectAsSqf(returned);
}
else
{
Logger.addMessage(Logger.LogType.Warning, "The database: " + database + " is not loaded in through the Databases.txt file.");
}

//Logger.addMessage(Logger.LogType.Info, "Returning false object");
return Arma2Net.Managed.Format.ObjectAsSqf(false);
return Format.ObjectAsSqf(false);
}
else
{
Expand Down
6 changes: 2 additions & 4 deletions Arma2NETMySQLPlugin/Arma2NETMySQLPlugin.csproj
Expand Up @@ -35,16 +35,14 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Program Files\Steam\steamapps\common\arma 2 operation arrowhead\@Arma2NET\AddInViews\AddInView.dll</HintPath>
</Reference>
<Reference Include="Arma2Net.Managed, Version=1.7.0.0, Culture=neutral, PublicKeyToken=8762987cc8e6095e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Program Files\Steam\steamapps\common\arma 2 operation arrowhead\@Arma2NET\Arma2Net.Managed.dll</HintPath>
<Reference Include="Arma2Net.AddInProxy">
<HintPath>..\..\..\..\..\..\Program Files\Steam\steamapps\common\arma 2 operation arrowhead\@Arma2NET\Arma2Net.AddInProxy.dll</HintPath>
</Reference>
<Reference Include="MySql.Data, Version=6.2.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\MySQL\MySQL Connector Net 6.2.4\Assemblies\MySql.Data.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.AddIn" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
Expand Down
3 changes: 2 additions & 1 deletion Arma2NETMySQLPlugin/MySQL.cs
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using System.Threading;
using MySql.Data.MySqlClient;
using Arma2Net.AddInProxy;

namespace Arma2NETMySQLPlugin
{
Expand Down Expand Up @@ -165,7 +166,7 @@ private string[][] RunOnDatabase(MySqlCommand command, int maxResultSize)
* The last character is reserved for null
*
*/
string formatted = Arma2Net.Managed.Format.ObjectAsSqf(string_array);
string formatted = Format.ObjectAsSqf(string_array);
int size = Encoding.UTF8.GetByteCount(formatted.ToCharArray());
//Logger.addMessage(Logger.LogType.Info, "Size length: " + size);
if (size > maxResultSize) {
Expand Down
5 changes: 2 additions & 3 deletions Arma2NETMySQLPlugin/Startup.cs
Expand Up @@ -2,9 +2,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.AddIn;
using AddInView;
using Arma2Net.Managed;
using Arma2Net.AddInProxy;

namespace Arma2NETMySQLPlugin
{
Expand All @@ -29,7 +28,7 @@ public static void StartupConnection()
//http://stackoverflow.com/questions/64602/what-are-differences-between-assemblyversion-assemblyfileversion-and-assemblyin
Logger.addMessage(Logger.LogType.Info, "Version number: " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());

Logger.addMessage(Logger.LogType.Info, "Compiled against Arma2NET Version: " + Utils.TargetFileVersion);
Logger.addMessage(Logger.LogType.Info, "Compiled against Arma2NET Version: " + Environment.Version);

//Load in Databases.txt file
//This also sets up the SQLProvider associated with the database
Expand Down
17 changes: 9 additions & 8 deletions ReadMe.html
Expand Up @@ -119,12 +119,10 @@ <h2>Contents</h2>
to create manually. Note that the call names are different between running stored procedures versus straight queries.</li>
</ul>
</ol>
<li>Run Arma2 and use this for your command line parameters (for the server which connects to the database):
<pre>-mod=expansion\beta;expansion\beta\expansion;@CBA;@CBA_A2;@CBA_OA;@Arma2NET -arma2netdev</pre>
<p>Alternatively, you can not use the -arma2netdev commandline parameter and just edit one of the settings file.
Open up Settings.yaml and set "DisableSandboxing" to true. Essentially, the reason why all of this is necessary
is because only approved "signed" versions of plugins are accepted when the sandbox is active. This allows third-party
plugins to be run.</p>
<li>Run Arma2 and add @Arma2NET as a mod. For example your command line parameters (for the server which connects to the database):
<pre>-mod=expansion\beta;expansion\beta\expansion;@Arma2NET</pre>
<p>This plugin doesn't require any other third party mods like ACE or CBA. But, they do have some nice utility functions
and features that may be helpful when you make your missions.</p>
<p>Arma2 player clients do not need to do any of this. They will interact with the Arma2 server and through SQF scripting, so you can
pass the information from the database back to them or use it however you need.</p>
</li>
Expand All @@ -139,7 +137,7 @@ <h2>Contents</h2>
<p>Arma2NETMySQL Plugin uses the callExtension function, however, there are some
<a href="http://community.bistudio.com/wiki/Extensions#A_few_technical_considerations">technical considerations</a> as part of this.
</p>
<p>Returning results has a limit of 4000 characters. If you try to run a MySQL query that will return a result longer than 4000 characters,
<p>Returning results has a limit of 4095 characters. If you try to run a MySQL query that will return a result longer than 4095 characters,
it will return the string "TooLong". Then you know you will need to limit the number of results that are returned. In MySQL,
you can use <a href="https://dev.mysql.com/doc/refman/5.0/en/select.html">the limit parameter</a>. This is a limitation of
Arma2 so don't ask for this to be fixed.</p>
Expand All @@ -157,13 +155,16 @@ <h2>Contents</h2>
These can get very long so scroll all the way to the bottom to see the latest run. This will tell you if you have an error in
your SQF scripting code or other such problems. Note, these path locations are for Windows 7 (and Vista?) and may be different
for other versions of Windows.</p>
<p>If you're still having problems, please go back and double check that you did everything correctly. If you skipped a step
or got an error and just decided to continue to the next step, nothing will work.</p>

<p>If you found a bug, please create an issue ticket here:
<a href="https://github.com/firefly2442/Arma2NETMySQLPlugin">Github page</a>.</p>
<p>There is also <a href="http://forums.bistudio.com/showthread.php?128795-Arma2MySQL">a thread</a>
on the <a href="http://forums.bistudio.com">BIS forums</a> so if you're stuck, you can ask there.
The forums are preferred over emailing me because then the question/answer is available to
future people who have similar problems.</p>
future people who have similar problems. If you post any questions anywhere, please post <b>ALL</b>
log files, otherwise we will have problems helping you.</p>

<a name="changelog"><h2>Changelog</h2></a>

Expand Down

0 comments on commit b61b777

Please sign in to comment.