Jump to content
Sign in to follow this  
infection

[Release] Arma2 SQL-Life 0.1

Recommended Posts

Nbs2NI6.png

Introduction

Hello there Arma community, I've now updated this with a much cleaner version. Arma2SQL Life is a way to save stats and variables in a life mission or any other mission but it would have to be reworked. I've always loved Life maps however one of the downsides is everyone is very protective of their code, map or in this case stat save. I wanted to create this for the community to use, share and further develop. The goal is to be simple yet effective, I hope I've achieved that, if not I will have to keep trying! I hope you will find these scripts useful for your server and community!

IMPORTANT NOTICE: If you ran the old version, the SQL save functions and database have been updated, you will need to update your database with the latest SQL file to add procedures and change variable types, else the latest version will not work! Also, CBA is no longer needed.

Documentation: http://infectiondg.github.io/

Requirements

  • Arma2NET
  • Arma2MySQL

Table of content

  1. Installation
  2. Commands
  3. Known issues
  4. Credits

1.INSTALLATION

  1. Please create a backup of your mission before attempting to install!
  2. Place SQL-Scripts folder in your mission root folder.
  3. Add this code to your INIT.SQF file in a isserver if statement.
    [] call compile preprocessFileLineNumbers "SQL-Scripts\server\savefunc.sqf";
    [] call compile preprocessFileLineNumbers "SQL-Scripts\server\serverevents.sqf";


  4. Add this code to your INIT.SQF in a isclient or !dedicatedserver if statement.
    [] call compile preprocessFileLineNumbers "SQL-Scripts\client\savefunc.sqf";
    [] call compile preprocessFileLineNumbers "SQL-Scripts\client\clientinit.sqf";


  5. Open Description.ext and add this line.
    #include "SQL-Scripts\dialogs\dialogs.hpp"


  6. Run the life_DB.sql query in your mysql server, please note this documentation does not cover installation of Arma2NET or Arma2MySQL.
  7. Done! Any issues contact Infection/Linnet on the BI forums, preferably in the Arma2SQL Life Thread.

2.COMMANDS

The default arguments follow from left to right in order.

[Player] call DB_LOAD

DB_LOAD calls the server to send a query to recieve your stats and send it back to you.

Default argument: Player

[Player, Int, Array, Array, Double] call DB_NEW

DB_NEW inserts a new save in your database.

Default arguments: Player, Bank, Inventory, License, Streetrep

[Player, Int, Array, Array, Double] call DB_SAVE

DB_SAVE updates all your variables and stats.

Default arguments: Player, Bank, Inventory, License, Streetrep

Additonal Commands

[string, string] call C_HINT

It hints in color.

Default argument: Text, Hex color code

[Array] call TO_ASCII

TO_ASCII turns your two-dimensional arrays into a single array of ASCII.

Default arguments: Inventory

[string] call TO_ARRAY

TO_ARRAY turns your single ASCII-filled array back into a two-dimensional array.

Default arguments: ASCII-array

3.Known Issues

  • Two-dimensional arrays cannot be passed to Arma2MySQL by default due to a bug with commas, the workaround is to use the TO_ASCII function, then passing the ASCII-array to Arma2MySQL. This is needed when passing the Inventory of a player due to it being a two-dimensional array.
  • Stats might not load or save correct during high load.
  • Car saving is not currently implemented due to being reworked.
  • Eventhandlers work pretty well but I'm not sure if it's the most efficent way to go about it, going to be looking into it.

Credits

Thanks to firefly2442 for creating Arma2MySQL.

Thanks to ScottNZ for creating Arma2NET.

This was created by Infection/Linnet, anyone may use and modify it but I ask that you keep the credits and do not try to claim it as your own.

Changelog

1.0.0

-Extreme code cleanup.

-Reworked two-dimensional arrays.

-Removed Vehicle save temprorarily.

-Renamed Functions.

-Updated SQL to run procedures instead of raw commands. (IMPORTANT THAT YOU UPDATE YOUR SQL DATABASE!)

-Database has been improved to be the proper variable types such as Int and Double.

-Documentation added!

-Changed the way to initalize it, see the new installation instructions.

0.1.3

-Insert improved to be more efficent.

0.1.2

-Fixed car saving (this includes the dialog saving).

-Added recreating vehicle function which puts it back to the impound lot after a restart. (IMPORTANT: This command is specificly for Island life you will need to change this accordingly to your mission variables. Look into createfunctions.sqf)

0.1.1

-Fixed an issue where user input would not be enabled after creating a new profile. Fixed that vehicle was a number instead of array by default therefor you could get stuck on loading screen due to script error.

0.1

-Initial release

Downloads

GitHub: https://github.com/Infectiondg/Arma2SQL-LIFE

Armaholic: http://www.armaholic.com/page.php?id=21852 //Armaholic might not be the most up-to-date version of Arma2SQL Life, after a recent update use github.

Edited by Infection
Major update

Share this post


Link to post
Share on other sites

I just updated it with a small fix.

It was not enabling user input when a new profile was created only when loading a profile.

Fixed that vehicle was a number instead of array by default therefor you could get stuck on loading screen due to script error.

Edited by Infection

Share this post


Link to post
Share on other sites

A question: Does the MySQL server need to be hosted on the same machine hosting the game server? Are there any details you're supposed to type in, etc db name, username, pass

Do I just simply run a MySQL server on XAMPP, then just query the life.sql file included?

Edited by takeonmarslover

Share this post


Link to post
Share on other sites
A question: Does the MySQL server need to be hosted on the same machine hosting the game server? Are there any details you're supposed to type in, etc db name, username, pass

Do I just simply run a MySQL server on XAMPP, then just query the life.sql file included?

No it does not need to be on the same server, see the database.txt file when installing Arma2Mysql.

Share this post


Link to post
Share on other sites

Hello;

I am very interested in this system, but I'm a noob and I have a question just try it before .

The player needs to download any type of file to play on a server that uses this system? or any player may enter the server without downloads?

Thank you.

Sorry my english.

Share this post


Link to post
Share on other sites
Hello;

I am very interested in this system, but I'm a noob and I have a question just try it before .

The player needs to download any type of file to play on a server that uses this system? or any player may enter the server without downloads?

Thank you.

Sorry my english.

Players do not need to download anything. Everything is server sided.

Share this post


Link to post
Share on other sites

Great Plugin, however we get it all working except one problem, the scripts do not write to the server database when you activate the save function. so character remain with the default config as per a new character in the database.

Share this post


Link to post
Share on other sites
Great Plugin, however we get it all working except one problem, the scripts do not write to the server database when you activate the save function. so character remain with the default config as per a new character in the database.

Which function?

Edit: also please show your arma2net log and arma2mysql log

Edited by Infection

Share this post


Link to post
Share on other sites

we added the

[] execVM "statsave\dialogs\savomat.sqf";

to the end of the atm.sqf file

so when the player uses the atm machine after using and withdrawing money the dialog box appears and they save stats, however it does not write the new information to the database.

whats the default directory for the arma2net log and arma2mysql log?

We get an error in the following file:

statsave/client/savefunc.sqf line 97 _vehname = _vehs select 1;

this is our server log:

Info: 12:34:06 - Logging started in directory: D:\Servers\TestServer\logs\
Info: 12:34:06 - Arma2NETMySQL Plugin Started.
Info: 12:34:06 - Version number: 0.1.0.0
Info: 12:34:06 - Loading databases...
Info: 12:34:06 - Databases.txt file loading in from: D:\Servers\TestServer\Databases.txt
Info: 12:34:06 - Type: mysql Database: life IPAddress: 127.0.0.1 Port: 3306 Username: arma Password: NotShownForSecurityReasons
Info: 12:34:37 - Received - Database: life SQL Query: SELECT uid, name, bank, inventory, license, streetrep, vehicle FROM users WHERE uid = '5582016' AND name = '[cv]TRIGGA' AND side = 'CIV'
Info: 12:34:38 - Received - Database: life SQL Query: INSERT into users (uid, name, side, bank, inventory, license, streetrep, vehicle) VALUES('5582016', '[cv]TRIGGA', 'CIV', '0', '0', '0', '0', '[]')
Info: 12:34:39 - Received - Database: life SQL Query: UPDATE users SET bank = '25000', inventory = 'schluesselbund`1`handy`2', license = '[]', streetrep = '0' WHERE uid = '5582016' AND name = '[cv]TRIGGA' AND side = 'CIV'
Info: 12:38:04 - Received - Database: life SQL Query: SELECT uid, name, bank, inventory, license, streetrep, vehicle FROM users WHERE uid = '5582016' AND name = '[cv]TRIGGA' AND side = 'CIV'
Info: 12:41:48 - Received - Database: life SQL Query: SELECT uid, name, bank, inventory, license, streetrep, vehicle FROM users WHERE uid = '5582016' AND name = '[cv]TRIGGA' AND side = 'CIV'

Edited by TriGGa

Share this post


Link to post
Share on other sites

Thanks for the find TriGGa, I accidentialy deleted an important line!

Update today

0.1.2

-Fixed car saving (this includes the dialog saving).

-Added recreating vehicle function which puts it back to the impound lot after a restart. (IMPORTANT: This command is specificly for Island life you will need to change this accordingly to your mission variables. Look into createfunctions.sqf)

Latest update can be found on Github!

Share this post


Link to post
Share on other sites
Thanks for the find TriGGa, I accidentialy deleted an important line!

Update today

0.1.2

-Fixed car saving (this includes the dialog saving).

-Added recreating vehicle function which puts it back to the impound lot after a restart. (IMPORTANT: This command is specificly for Island life you will need to change this accordingly to your mission variables. Look into createfunctions.sqf)

Latest update can be found on Github!

Perfect working now, any tips on how to create an autosave for this feature, like say autostat save every 10 min?

or perhaps a setup so it saves after every transaction ie paycheck, fine paid give drop or receive money.

Otherwise unless the player saves the stats they could manipulate the economy by giving money to a friend respawning in with there old data and doing it again.

Share this post


Link to post
Share on other sites
Perfect working now, any tips on how to create an autosave for this feature, like say autostat save every 10 min?

or perhaps a setup so it saves after every transaction ie paycheck, fine paid give drop or receive money.

Otherwise unless the player saves the stats they could manipulate the economy by giving money to a friend respawning in with there old data and doing it again.

Yes, I have this implemented on our servers, look into transactions.sqf, addlicense.sqf, shopdialog or shoptransaction (I can't remember which one) and you can add saving after each salaray in salaries.sqf.

I'd like to point out I'm not too certain how efficent it is saving too many times. If you run a full servers say 46-60 people could possibly cause lag. Needs to be tested tho!

Share this post


Link to post
Share on other sites
Yes, I have this implemented on our servers, look into transactions.sqf, addlicense.sqf, shopdialog or shoptransaction (I can't remember which one) and you can add saving after each salaray in salaries.sqf.

I'd like to point out I'm not too certain how efficent it is saving too many times. If you run a full servers say 46-60 people could possibly cause lag. Needs to be tested tho!

Yeah i thought it might cause a bit of lag saving all the time. Anyway to save the data without causing the interface to pop up, a simple [] execVM "blahblah.sqf"; at the bottom of the files yo edit to prompt the save perhaps?

Also looking to add an option to have a manual save feature for the player with the scroll wheel.

Share this post


Link to post
Share on other sites

having the player save their stuff via their own personal addaction etc - probably not the best idea. Found that few errors start to occur if done at same time as other, as the server can only save/call one at a time. You could create a system that waits unitl a call save is made... just a thought.

Haven't played this game but perhaps have the save points when a player dies and when he disconnects. - Again just a thought

Share this post


Link to post
Share on other sites
having the player save their stuff via their own personal addaction etc - probably not the best idea. Found that few errors start to occur if done at same time as other, as the server can only save/call one at a time. You could create a system that waits unitl a call save is made... just a thought.

Haven't played this game but perhaps have the save points when a player dies and when he disconnects. - Again just a thought

I would like to make it save when a player disconnects however the function to initate the save is sent from the client together wtih all the variables so onplayerdisconnect wouldn't work (I think atleast, it has to be run on server correct?). Any ideas on how I could accomplish this without onplayerdisconnect?

Share this post


Link to post
Share on other sites
Yes, I have this implemented on our servers, look into transactions.sqf, addlicense.sqf, shopdialog or shoptransaction (I can't remember which one) and you can add saving after each salaray in salaries.sqf.

I'd like to point out I'm not too certain how efficent it is saving too many times. If you run a full servers say 46-60 people could possibly cause lag. Needs to be tested tho!

what i was getting at was:

what line of code have you added to these files to do this, and can it be done without the dialog box opening...ie hidden save.

Share this post


Link to post
Share on other sites

im just on my way out - i can assist you with this when i get back - i think onplayerdisconnect is the same as onplayerconnected that it only runs on the server.

I have it saving on joining and disconnecting no problem, so it can be done. maybe have a chat about this swap ideas etc...

Share this post


Link to post
Share on other sites

what about on player spawn or respawn aswell as player connect / disconnect, incase a player just goes back to lobby and respawns or swaps character or role..

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  

×