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

If you want to automatically save and load, you don't need any code running on the client, probably.

serverSaveData.sqf:

while{true} do {
{
	if(isPlayer _x) then {
		// Save their data here
	};
} forEach allUnits;
};

Then in the player init (the character initialization) and respawn event handler, set their loadout.

and how would i exev the serversavedata? Just Exev within init.sql or anything specific?

Share this post


Link to post
Share on other sites

My init file was missing the preprocess... alltime, God i am a potato

---------- Post added at 14:33 ---------- Previous post was at 13:11 ----------

My init file was missing the preprocess... alltime, God i am a potato

Right saving is now working, but how do i cause the server to give player their profile as they connect?

Edited by DukeRevenger

Share this post


Link to post
Share on other sites

give them a respawn event handler, I suppose.

In the editor, in the unit initialization do:

nil=[] execVM "initPlayer.sqf";

then in there, you add the handler:

_unit addEventHandler["Respawn", {
//load stuff here I guess?
}];

Or you could set a variable, etc. There's lots of ways.

Share this post


Link to post
Share on other sites
give them a respawn event handler, I suppose.

In the editor, in the unit initialization do:

nil=[] execVM "initPlayer.sqf";

then in there, you add the handler:

_unit addEventHandler["Respawn", {
//load stuff here I guess?
}];

Or you could set a variable, etc. There's lots of ways.

thing is, it shoud only load once they connect not on respawn and trying to get it work on JIP players, as on our server if death evrythings gone, Levels etc,

Share this post


Link to post
Share on other sites
Then you want it to be in the player initPlayer.sqf (without the event handler)

Diden't work out, How would i execute it so it loads? It works for me but not someone on my server, Their save file works but not load

Share this post


Link to post
Share on other sites

Make sure you're only executing the loading stuff if isServer is true, and if the server can't properly set the loadout (it really should be able to) then try setting a variable and transferring the data.

Share this post


Link to post
Share on other sites
Make sure you're only executing the loading stuff if isServer is true, and if the server can't properly set the loadout (it really should be able to) then try setting a variable and transferring the data.

hmm..

I got the playerinit.sqf as

if(!isServer) exitWith {};
_unit = _this;
_Profile = format["%1", getPlayerUID _unit];
_unit = [_Profile,"playerdata", "position", "ARRAY"] call iniDB_read; <<<< just realised that.. FML
_unit = [_Profile,"playerdata", "position", "ARRAY"] call iniDB_read; <<<< just realised that.. FML - diden't help :/
_unit setpos (_Pos);
_unit setscore (_Score);

and initlize on unit as

nil=[] execVM "playerinit.sqf";

yet dosent work, Am i doign something extreamly wrong?

Edited by DukeRevenger

Share this post


Link to post
Share on other sites

You're coding that completely incorrectly.

if(!isServer) exitWith {};
_unit = _this;
_profile = format["%1", getPlayerUID _unit];
_position = [_profile, "playerdata", "position", "ARRAY"] call iniDB_read;
_score = [_profile, "playerdata", "score", "NUMBER"] call iniDB_read;
_unit setPos _position;
_unit setScore _score;

Then in the init:

0=this execVM "playerinit.sqf";

What you're doing extremely wrong is you did not read up on the scripting language.

I know it's inconsistent, hard to understand and well... no apologies for the language itself, but you should learn the fundamentals before tackling something like this.

Edited by SicSemperTyrannis

Share this post


Link to post
Share on other sites
You're coding that completely incorrectly.

if(!isServer) exitWith {};
_unit = _this;
_profile = format["%1", getPlayerUID _unit];
_position = [_profile, "playerdata", "position", "ARRAY"] call iniDB_read;
_score = [_profile, "playerdata", "score", "NUMBER"] call iniDB_read;
_unit setPos _position;
_unit setScore _score;

Then in the init:

nil=this execVM "playerinit.sqf";

What you're doing extremely wrong is you did not read up on the scripting language.

I know it's inconsistent, hard to understand and well... no apologies for the language itself, but you should learn the fundamentals before tackling something like this.

that is fully correct and i won't deny the fact i did not read up on SQF I learnt by misstake/people's help mostly, but even with this given, I can't get it to work, I start beliving my IQ is to low to execute this correctly :p

also gonna include This is my init

call compile preProcessFile "\iniDB\init.sqf";
if(isServer) then {
[] execVM "save.sqf";};

save.sqf

if(isServer) then {
while{true} do {
{
	if(isPlayer _x) then {
		sleep 5;
_Profile = format["%1", getPlayerUID _x];
[_Profile, "playerData", "position", position _x] call iniDB_write;
[_Profile, "playerData", "Playername", name _x] call iniDB_write;
[_Profile, "playerData", "magazines", magazines _x] call iniDB_write;
[_Profile, "playerData", "score", score _x] call iniDB_write;
	};
} forEach allUnits;
}
};

Also big thanks for giving all this help SicSemperTyrannis, even if im a potato when it comes to this kind of coding, more of local builder :/

Edited by DukeRevenger

Share this post


Link to post
Share on other sites
what about a simple demo mission ?

I said earlier that I'd post one eventually, but right now I simply do not have the time. I'm working on my own mode.

Share this post


Link to post
Share on other sites
nil=this execVM "playerinit.sqf";

This is BIG NO NO! Use forum search on nil assignment.

Use

_dummyReturn =

MyDummyReturn =

nul =

0 =

Share this post


Link to post
Share on other sites
Fixed it, then.

Am i doing something wrong in my init file if it looks like

call compile preProcessFile "\iniDB\init.sqf";
0=this execVM "playerinit.sqf";
if(isServer) then {
[] execVM "save.sqf";};

as it still seems to only load the clients ini files not servers

Share this post


Link to post
Share on other sites

Hi, what a great utility for already a great game! Does this also work for ARMA 2? (Or does the scripts make use of the newer ARMA 3 scripting commands?)

The reason why I am asking this, is because we are very very eager to use this on our Wasteland Mission. Expanding it with the so-called by players manually locked objects like bases and basecomponents.

Share this post


Link to post
Share on other sites

Arrgg.. still no success here, i'm defo doing something wrong Is it suppose to be running of the init.sqf as posted above or where am i failing, plus server gets the yellow mark when running @inidb :/

Share this post


Link to post
Share on other sites

There's no loops or anything that would cause yellow chain. There's nothing especially intensive about the code.

If there's problems, it's with the script. Perhaps you'd have better luck asking in script help topics.

Share this post


Link to post
Share on other sites
There's no loops or anything that would cause yellow chain. There's nothing especially intensive about the code.

If there's problems, it's with the script. Perhaps you'd have better luck asking in script help topics.

Diden't mean chains, ment the icon in server list for missmatch on addons :p ain't it suppose to be server only?

Share this post


Link to post
Share on other sites

i get the concept behind the write and read functions and the savePlayerData.sqf looks very reasonable to me but how do i initialize the database itself and where is it located. just for testing purposes i have central script running in a loop that uses your example savePlayerData.sqf to save the data of all players every few seconds. so where is that data stored? how can i know it's saving?

Share this post


Link to post
Share on other sites

It's stored in /@inidb/db/

The first parameter of the write/read function is the file name, just not the entire file name (since it's not needed and can cause exploits).

So,

_fileName = format["PlayerID_%1", getPlayerUID _unit];

Would be like:

/@inidb/db/PlayerID_123456.ini

Share this post


Link to post
Share on other sites

First, this is a great system, works very well, but I have 1 problem and hopefully someone can help me out with it.

This makes no sense to me as to why this doesn't work, and is regarding weapons & magazines loading, everything else loads perfectly fine and has no issue.

First My Save variable

_Profile		= format["%1", getPlayerUID player];
[_Profile, "playerData", "Weapons", weapons player] call iniDB_write;
[_Profile, "playerData", "Ammo", magazines player] call iniDB_write;

Then my loading info which executes in the same file, same time, as all the other variables which load perfectly fine.

_Weps		= [_Profile, "playerdata", "Weapons", "ARRAY"] call iniDB_read;
_Mags		= [_Profile, "playerdata", "Ammo", "ARRAY"] call iniDB_read;

And currently I have it as

player addWeapon _Weps;

I've tried (_Weps); , this addWeapon _Weps; , (_Weps); , I've literally tried everything I know, and it just will not give the weapons or mags, if anyone has gotten it to load the mags and weapons without issues... please share :(

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  

×