Jump to content
Sign in to follow this  
SicSemperTyrannis

iniDB - Save and Load data to the server or your local computer without databases!

Recommended Posts

We have a problem hosting our official life server, multiple times it does not save a players money and they will lose it when they restart, any suggestions or clues?

Share this post


Link to post
Share on other sites

@All3n: Make sure their money isn't set to the default value when the load in. I accomplished this by using an isNil check for a variable I passed from the server.

Share this post


Link to post
Share on other sites

Thanks for this wonderful system!

I'm using this as the database for my Stratis-RP mission I'm currently developing from scratch.

You sure did give me a headache though tonight! >.<

I had to come up with solutions in order to keep the entire system server side, and have clients request the info from the server while having the server use the info sent to it for its own use in order seek out the info from the database, then send the info back to the clients, and have the clients filter through the received info to ensure that it belongs to them.

But I got it working to practical-use!

Share this post


Link to post
Share on other sites
^^ sounds complicated !

Oh it was, lol.

Share this post


Link to post
Share on other sites

I tried to make a function for saving data on database in a clientside script. I can write to database, but it was not possible to read data.

Code

Client


if(isServer) exitWith {};

db_write = {

private ["_puid", "_unit"];

_unit = player;
_puid = getPlayerUID _unit;

// Query: database[0] - table[1] - table[2] - value[3]

// Write to DB 
dbQuery = [_unit,_puid, 1,_this select 0,_this select 1,_this select 2,_this select 3];
publicVariableServer "dbQuery";

};

db_read = {

private ["_puid", "_unit"];

_unit = player;
_puid = getPlayerUID _unit;

// Query: database[0] - table[1] - variable[2] - datatype[3]

// Read from DB
dbQuery = [_unit,_puid, 0,_this select 0,_this select 1,_this select 2,_this select 3];
publicVariableServer "dbQuery";

"dbRead" addPublicVariableEventHandler { queryresult = _this select 1 };

queryresult

};

Server


if(!isServer) exitWith {};

// Passed array:  PLAYEROBJECT[0] - GUID[1] - READ[2] or WRITE[2] - DATABASE[3] - TABLE[4] - VARIABLE[5] - VALUE[6] or DATATYPE[6]
"dbQuery" addPublicVariableEventHandler { _clientData =_this select 1;

	switch(_clientData select 2)do
	{

		case 0:
		{	
			dbRead = [_clientData select 3, _clientData select 4, _clientData select 5, _clientData select 6] call iniDB_read;

			owner _clientData select 0 publicVariableClient "dbRead";

		};

		case 1:
		{
			[_clientData select 3, _clientData select 4, _clientData select 5,_clientData select 6] call iniDB_write;

		};

	};

};

I hope someone knows how to fix this. I'm not sure but I think it has to do with owner function or return value of my client function.

It would make everything easier with it.

Share this post


Link to post
Share on other sites

Having followed the steps to install this on our server and using DukeRevenger's code we get the error "Script iniDB\init.sqf not found" anyone have any idea's how to prevent/fix this?

Thanks

Share this post


Link to post
Share on other sites
Having followed the steps to install this on our server and using DukeRevenger's code we get the error "Script iniDB\init.sqf not found" anyone have any idea's how to prevent/fix this?

Thanks

Try running the mod on your server. It helps

Share this post


Link to post
Share on other sites
Try running the mod on your server. It helps

Thank you for your very helpful and informative reply, maybe I shall try that next time or maybe you can re-read my original post, particularly the part that reads "Having followed the steps to install this on our server......"

To add a little more info, we are spawning with no uniform, just shorts and backpack but that maybe due to us needing to make some edits in one of the files. The db folder is logging players details, uniform, kit, position etc its just not loading up probably due to our original error with the script not found.

Regards

Edited by uberlamo

Share this post


Link to post
Share on other sites

I'm currently trying to get this to work, however I'm running into a little problem where the file won't get written, I've tried most of the example's provided in this thread.

"C:\Program Files (x86)\Steam\SteamApps\common\Arma 2 Operation Arrowhead\arma2oaserver.exe" -config=server.cfg -mod=@inidb that's my Arma 2 server shortcut.

I'm trying it with http://forums.bistudio.com/showthread.php?150293-iniDB-Save-and-Load-data-to-the-server-or-your-local-computer-without-databases!&p=2358270&viewfull=1#post2358270

yet nothing happens when I run the server, I've tried running it as admin. Any Ideas?

Edited by Infection

Share this post


Link to post
Share on other sites
Having followed the steps to install this on our server and using DukeRevenger's code we get the error "Script iniDB\init.sqf not found" anyone have any idea's how to prevent/fix this?

Thanks

I am also having this issue...:(

But without using DukeRevenger's code.

Edited by Gand

Share this post


Link to post
Share on other sites

would anyone help me get this working for Stratis life?

Share this post


Link to post
Share on other sites

Hi there,

first of all, thanks for your work.

I have problems running your mod. Saving is working just like a charm but loading is just not working, here's what i've done:

in init.sqf:

call compile preProcessFile "\iniDB\init.sqf";

I then made a simple

["myfile", "server", "starttime", date] call iniDB_write;

this works. myfile is being created and the expected entry does also exist.

Then I make this:

_ret = ["myfile", "server", "starttime", "ARRAY"] call iniDB_read;

This results in an error complaining about _data is not set. While playing around I moved the read code into a spawn, to have the result in the next frame.

The error vanishes but I don't get a result, just 'nil'.

Can you please give me a hint?! It seems for me that I'm doing everything right.. ;-)

Edit:

I'm running this local, not on a dedicated server (for testing purposes)

Edited by lotherk

Share this post


Link to post
Share on other sites

Hello. I am having a problem installing it in mine.. Let me tell you the steps of what I did.

1. Downloaded it.

2. I placed the '@inidb" in my arma 2 root.

C:\Program Files (x86)\Bohemia Interactive\ArmA 2

3. I placed "call compile preProcessFile "\iniDB\init.sqf";" in my Takistan PBO in the file called "init.sql"

4. Recreated the pbo and put it in my MPmission folder.

5. Started the server.

Is there anything I need to edit? Did I forget to add something? Thanks guys.

Share this post


Link to post
Share on other sites
Hello. I am having a problem installing it in mine.. Let me tell you the steps of what I did.

...

Is there anything I need to edit? Did I forget to add something? Thanks guys.

Did you add "-mod=@inidb" to your server line command ?

Btw, zooloo75 did an awesome job with Stratis-RP: Ultimate.

People should take a look to few files :

init.sqf, compile.sqf, and all .sqf files in /statSave, it helped me a lot to find how to script with iniDB.

Thank you too SicSemperTyrannis for your amazing addon.

Share this post


Link to post
Share on other sites
Did you add "-mod=@inidb" to your server line command ?

Btw, zooloo75 did an awesome job with Stratis-RP: Ultimate.

People should take a look to few files :

init.sqf, compile.sqf, and all .sqf files in /statSave, it helped me a lot to find how to script with iniDB.

Thank you too SicSemperTyrannis for your amazing addon.

Thanks I forgot. Will test it now and yes that Stratis RP looks awesome.. :) Looking forward to it.

---------- Post added at 15:44 ---------- Previous post was at 15:19 ----------

Update. I just did that restarted playing for about 30 minute and its a no go. Still did not work.

1. Downloaded it.

2. I placed the '@inidb" in my arma 2 root.

C:\Program Files (x86)\Bohemia Interactive\ArmA 2

3. I placed "call compile preProcessFile "\iniDB\init.sqf";" in my Takistan PBO in the file called "init.sql"

4. Recreated the pbo and put it in my MPmission folder.

5. Opened the server.bat and added ""-mod=@inidb""

6. Started the server.

7. Played for 30 minutes

Share this post


Link to post
Share on other sites
3. I placed "call compile preProcessFile "\iniDB\init.sqf";" in my Takistan PBO in the file called "init.sql"

4. Recreated the pbo and put it in my MPmission folder.

3.5. Write save and load functions.

You did it ?

Share this post


Link to post
Share on other sites

You should read the entire thread.

Edited by MikeMuir

Share this post


Link to post
Share on other sites

I was reading it. I dont see where it says I need to create anything. I am just looking for some help here. I mean if I need to create something I will. I will pay someone to fix this. :) Just need some help..

http://i42.tinypic.com/97r39c.png (229 kB)

Share this post


Link to post
Share on other sites

Sorry for the stupid question, but I've read the entire thread and can't seem to find where the load and save .sqf's go. I must not be putting them in the correct place as the server is recognizing the mod, but not saving/loading anything.

Share this post


Link to post
Share on other sites

How do I use the iniDB_exists in a loop?

_count = 0;
{
while {!("Houses" call iniDB_exists) and (_count < (count Houses))} do {
	["Houses", _x, "Owner", "None"] call iniDB_write;
	["Houses", _x, "OwnerName", "None"] call iniDB_write;
	_count = _count + 1;
};
} forEach Houses;

It's only doing the write commands for one of the elements. How do I do this properly?

EDIT:

Changed that code to:

if (!("Houses" call iniDB_exists)) then {
_h = execVM "Server\setHouseMarkers.sqf";
waitUntil {scriptDone _h};
};

setHouseMarkers.sqf:

{
["Houses", _x, "Owner", "None"] call iniDB_write;
["Houses", _x, "OwnerName", "None"] call iniDB_write;
} forEach Houses;

Edited by eagledude4

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  

×