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

Your code is probably executing on the client, not the server.

"player" is a local variable for the client, you should be executing it on the server.

Look at it like this: They don't have @inidb installed, if they did it might work but they're not required to do this.

What you want to do is make the saveLoadout.sqf function send data to the server scripts via some function designed to send that data.

For example,

player setVariable["triggerSave", true, true]; // the third "true" makes sure this is broadcast to the server

then on the server side

serverSaveData.sqf ->

if(!isServer) exitWith {};

{
if((_x getVariable["triggerSave", false])) then {
	// Save data to ini file here
};
} forEach allUnits;

You'd probably want to call this in a loop. To load the data you'd follow a similar concept.

Could I (we) get a more "indepth" example of this? Like just saving the location would be super useful!

Share this post


Link to post
Share on other sites

Following this with interest ! Is it also possible to save the units CURRENT order?

Share this post


Link to post
Share on other sites
Following this with interest ! Is it also possible to save the units CURRENT order?

If it can be converted to a string, number or array it can be saved and loaded. I don't know if that answers your question.

Share this post


Link to post
Share on other sites

Right to assist the bambies that gotten same confused as i have, This is how i got mine working in the end ;

Init.sqf

call compile preProcessFile "\iniDB\init.sqf";
call compile preProcessFile "Arma3functions.sqf";
execVM "load.sqf";
abc_LoadplayerPos = {
   private ["_loadpos"];
   _loadpos = _this select 0;
   _Profile = format["%1", getPlayerUID _loadpos];
   _Pos = [_Profile, "playerData", "position", "ARRAY"] call iniDB_read;
   _weaponadd = [_Profile, "playerData", "weapons", "ARRAY"] call iniDB_read;
_weaponadd1 = [_Profile, "playerData", "weapons1", "STING"] call iniDB_read;
   _itemsadd = [_Profile, "playerData", "magazines", "ARRAY"] call iniDB_read;
_vestadd = [_Profile, "playerData", "vest", "STING"] call iniDB_read;
_uniformadd = [_Profile, "playerData", "uniform", "STING"] call iniDB_read;
_helmetadd = [_Profile, "playerData", "headgear", "STING"] call iniDB_read;
_loadpos setpos _Pos;
for "_i" from 0 to (count _itemsadd) do {_loadpos addMagazine (_itemsadd select _i)};
for "_y" from 0 to (count _weaponadd) do {_loadpos addweapon (_weaponadd select _y)};
_loadpos addvest _vestadd;
_loadpos adduniform _uniformadd;
_loadpos addheadgear _helmetadd;
hint format["%1",_pos];
   // Code goes here!
};



if(isServer) then {
[] execVM "save.sqf";};

Load.sqf

player addbackpack "B_Bergen_sgg";
removeallweapons player;
removeuniform player;
removeheadgear player;
removevest player;
[player] call abc_LoadplayerPosServer;

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", "weapons", Weapons _x] call iniDB_write;
[_Profile, "playerData", "weapons1", SecondaryWeapon _x] call iniDB_write;
[_Profile, "playerData", "vest", vest _x] call iniDB_write;
[_Profile, "playerData", "uniform", uniform _x] call iniDB_write;
[_Profile, "playerData", "headgear", headgear _x] call iniDB_write;
[_Profile, "playerData", "items", items _x] call iniDB_write;
	};
} forEach allUnits;
}
};

and the Arma3functions - Generated file via using ASCOM Framework

// Do not edit this file!
// This file may only be edited by Engima's ASCOM Editor!
//
// <ASCOM version="1">
// <Prefix>abc_</Prefix>
// <Functions>
// <Function Name="LoadplayerPos" Params="loadpos" Ret="false" A="false" C="false" S="true" O="false" OC="false" P="false" />
// <Function Name="LoadPlayerWeapon" Params="weapon" Ret="false" A="false" C="false" S="true" O="false" OC="false" P="false" />
// </Functions>
// </ASCOM>

ASCOM_ClientID = 0;
ASCOM_CallID = 0;
ASCOM_LastCallID = 0;
ASCOM_LockCallID = 0;

"abc_LoadplayerPosEventArgs" addPublicVariableEventHandler {
   private ["_array"];

   _array = _this select 1;

   _array spawn {
       if ((_this select 0 == "A") || (_this select 0 == "C" && !isDedicated)) then {
           (_this select 1) call abc_LoadplayerPos;
       };

       if (_this select 0 == "S" && isServer) then {
           (_this select 1) call abc_LoadplayerPos;
       };
   };
};

abc_LoadplayerPosServer = {
   if (isNil "_this") then { _this = []; };
   if (isServer) then {
       _this call abc_LoadplayerPos;
   }
   else {
       abc_LoadplayerPosEventArgs = ["S", _this];
       publicVariable "abc_LoadplayerPosEventArgs";
       abc_LoadplayerPosEventArgs = [];
   };
};


"abc_LoadPlayerWeaponEventArgs" addPublicVariableEventHandler {
   private ["_array"];

   _array = _this select 1;

   _array spawn {
       if ((_this select 0 == "A") || (_this select 0 == "C" && !isDedicated)) then {
           (_this select 1) call abc_LoadPlayerWeapon;
       };

       if (_this select 0 == "S" && isServer) then {
           (_this select 1) call abc_LoadPlayerWeapon;
       };
   };
};

abc_LoadPlayerWeaponServer = {
   if (isNil "_this") then { _this = []; };
   if (isServer) then {
       _this call abc_LoadPlayerWeapon;
   }
   else {
       abc_LoadPlayerWeaponEventArgs = ["S", _this];
       publicVariable "abc_LoadPlayerWeaponEventArgs";
       abc_LoadPlayerWeaponEventArgs = [];
   };
};



if (isServer) then {
   "ASCOM_AskForClientID" addPublicVariableEventHandler {
       private ["_unit"];

       _unit = _this select 1;
       ASCOM_AskForClientID = [];
       ASCOM_LastCallID = ASCOM_LastCallID + 1;
       ASCOM_ClientIDResponse = [_unit, ASCOM_LastCallID];
       publicVariable "ASCOM_ClientIDResponse";
   };

   ASCOM_ServerInitialized = true;
   publicVariable "ASCOM_ServerInitialized";
   ASCOM_Initialized = true;
}
else {
   "ASCOM_ClientIDResponse" addPublicVariableEventHandler {
       private ["_array"];

       _array = _this select 1;
       ASCOM_ClientIDResponse = [];

       if (player == (_array select 0)) then {
           ASCOM_ClientID = _array select 1;
           ASCOM_Initialized = true;
       };
   };

   waitUntil {!isNull player};
   ASCOM_AskForClientID = player;
   publicVariable "ASCOM_AskForClientID";
};

This works for me and players on my server to save most gear + pos,

Edited by DukeRevenger
Typo

Share this post


Link to post
Share on other sites

that's crazy, i made one about a month before this post:

dllmain.cpp

//DOA for Global Chaos Gaming <imagotrigger@gmail.com>
#define WIN32_LEAN_AND_MEAN
#include <time.h>
#include <windows.h>
#include <stdio.h>

BOOL APIENTRY DllMain( HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
	if (lpReserved != NULL) {
		//arma2oaserver is shutdown
	}
	break;
}
return TRUE;
}

extern "C"
{
 __declspec(dllexport) void __stdcall RVExtension(char *output, int outputSize, const char *function);
};

void __stdcall RVExtension(char *output, int outputSize, const char *function)
{
outputSize -= 1;
if (!strcmp(function,"version")) {
	strncpy(output,"gc.dll version 1.2 RAMdisk",outputSize);
} else if(!strcmp(function,"epoch")) {
	time_t ltime;
	time( &ltime );
	sprintf(output, "%ld", ltime );
} else if(!strncmp(function,"W",1)) {
	char input[8192] = "";
	strcpy(input,function);
	char * token = strtok( input, "|" );
	char * pid = strtok( NULL, "|" );
	char * name = strtok( NULL, "|" );
	char *p1;
	while((p1=strpbrk(name,"["))!=NULL)
       *p1='`';
	char *p2;
	while((p2=strpbrk(name,"]"))!=NULL)
       *p2='"';
	char * key = strtok( NULL, "|" );
	char * value = strtok( NULL, "|" );
	char file[256] = "";
	sprintf(file,"R:\\%s.ini",pid);
	if (WritePrivateProfileStringA(name,key,value,file)) {
		if (strcmp(pid,"__SERVER__") != 0) {
			time_t ltime;
			time( &ltime );
			char ztime[128] = "";
			sprintf(ztime, "%ld", ltime );
			WritePrivateProfileStringA(".","TLS",ztime,file);
		}
		strncpy(output,"1",outputSize);
	} else {
		strncpy(output,"0",outputSize);
	}
} else if(!strncmp(function,"R",1)) {
	char file[256] = "";
	char input[8192] = "";
	strcpy(input,function);
	char * token = strtok( input, "|" );
	char * pid = strtok( NULL, "|" );
	char * name = strtok( NULL, "|" );
	char *p1;
	while((p1=strpbrk(name,"["))!=NULL)
       *p1='`';
	char *p2;
	while((p2=strpbrk(name,"]"))!=NULL)
       *p2='"';
	char * key = strtok( NULL, "|" );
	sprintf(file,"R:\\%s.ini",pid);
	GetPrivateProfileStringA(name,key,NULL,output,outputSize,file);
} else if(!strncmp(function,"D",1)) {
	char input[8192] = "";
	strcpy(input,function);
	char * token = strtok( input, "|" );
	char * pid = strtok( NULL, "|" );
	char * key = strtok( NULL, "|" );
	char file[256] = "";
	sprintf(file,"R:\\%s.ini",pid);
	WritePrivateProfileSectionA(key,NULL,file);
} else {
   strncpy(output,"unknown function",outputSize);
}
}

functions: "version" "epoch" "R" "W" and "D"

example:

_actual_server_time_in_seconds = "thedll" callExtension "epoch";

_value_from_key_in_file = "thedll" callExtension format["R|%1|%2|%3","filename_wo_ini","section name in ini","key name"];

_nothing = "thedll" callExtension format["W|%1|%2|%3|%4","filename_wo_ini","section name in ini","key name","value"];

_nothing = "thedll" callExtension "D|filename_wo_ini|section_to_wipe_out";

---------- Post added at 13:59 ---------- Previous post was at 13:48 ----------

here is code i use to save all weapons/ammon on ground and load it

"gc" callExtension "D|__SERVER__|GC_WeaponHolders";
_counter = 0;
{
_pos = getposASL _x;
_dir = getdir _x;
_weps = getWeaponCargo _x; 
_mags = getMagazineCargo _x; 
_class = typeof _x;
_arr = [_pos,_dir,_weps,_mags,_class];
"gc" callExtension format["W|%1|%2|%3|%4","__SERVER__","GC_WeaponHolders",_counter,_arr];
_counter = _counter + 1;
} foreach (worldCenterPosition nearObjects ["WeaponHolder", 8000]);
diag_log text format["Wrote %1 dropped weapons/mags",_counter];

//dropped weapons
_counter = 0;
while{true} do {
_read = "gc" callExtension format["R|%1|%2|%3","__SERVER__","GC_WeaponHolders",_counter];
if (_read == "") exitWith {};
_read = call compile _read;
_pos = _read select 0;
_dir = _read select 1;
_weps = _read select 2;
_mags = _read select 3;
_class = _read select 4;
_code = "";
if (count _weps > 0) then {
	_weptypes = _weps select 0;
	_wepcounts = _weps select 1;
	{
		_code = _code + format['this addweaponcargo ["%1",%2];',_x,(_wepcounts select _foreachindex)];
	} foreach _weptypes;
};
if (count _mags > 0) then {
	_magtypes = _mags select 0;
	_magcounts = _mags select 1;
	{
		_code = _code + format['this addmagazinecargo ["%1",%2];',_x,(_magcounts select _foreachindex)];
	} foreach _magtypes;
};
_holder = createVehicle [_class, _pos, [], 0, "CAN_COLLIDE"];
diag_log _read;
_holder setposASL _pos;
_holder setdir _dir;
_holder setVehicleInit format['%1',_code];
processInitCommands;
_counter = _counter + 1;
};

Edited by Imago

Share this post


Link to post
Share on other sites

if you don't do any fancy local data saving stuff and just save data for the clients on the server you only will need the addon on the server since that's where the functions it contains will run.

Share this post


Link to post
Share on other sites
Right to assist the bambies that gotten same confused as i have, This is how i got mine working in the end ;

Init.sqf

call compile preProcessFile "\iniDB\init.sqf";
call compile preProcessFile "Arma3functions.sqf";
execVM "load.sqf";
abc_LoadplayerPos = {
   private ["_loadpos"];
   _loadpos = _this select 0;
   _Profile = format["%1", getPlayerUID _loadpos];
   _Pos = [_Profile, "playerData", "position", "ARRAY"] call iniDB_read;
   _weaponadd = [_Profile, "playerData", "weapons", "ARRAY"] call iniDB_read;
_weaponadd1 = [_Profile, "playerData", "weapons1", "STING"] call iniDB_read;
   _itemsadd = [_Profile, "playerData", "magazines", "ARRAY"] call iniDB_read;
_vestadd = [_Profile, "playerData", "vest", "STING"] call iniDB_read;
_uniformadd = [_Profile, "playerData", "uniform", "STING"] call iniDB_read;
_helmetadd = [_Profile, "playerData", "headgear", "STING"] call iniDB_read;
_loadpos setpos _Pos;
for "_i" from 0 to (count _itemsadd) do {_loadpos addMagazine (_itemsadd select _i)};
for "_y" from 0 to (count _weaponadd) do {_loadpos addweapon (_weaponadd select _y)};
_loadpos addvest _vestadd;
_loadpos adduniform _uniformadd;
_loadpos addheadgear _helmetadd;
hint format["%1",_pos];
   // Code goes here!
};



if(isServer) then {
[] execVM "save.sqf";};

Load.sqf

player addbackpack "B_Bergen_sgg";
removeallweapons player;
removeuniform player;
removeheadgear player;
removevest player;
[player] call abc_LoadplayerPosServer;

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", "weapons", Weapons _x] call iniDB_write;
[_Profile, "playerData", "weapons1", SecondaryWeapon _x] call iniDB_write;
[_Profile, "playerData", "vest", vest _x] call iniDB_write;
[_Profile, "playerData", "uniform", uniform _x] call iniDB_write;
[_Profile, "playerData", "headgear", headgear _x] call iniDB_write;
[_Profile, "playerData", "items", items _x] call iniDB_write;
	};
} forEach allUnits;
}
};

and the Arma3functions - Generated file via using ASCOM Framework

// Do not edit this file!
// This file may only be edited by Engima's ASCOM Editor!
//
// <ASCOM version="1">
// <Prefix>abc_</Prefix>
// <Functions>
// <Function Name="LoadplayerPos" Params="loadpos" Ret="false" A="false" C="false" S="true" O="false" OC="false" P="false" />
// <Function Name="LoadPlayerWeapon" Params="weapon" Ret="false" A="false" C="false" S="true" O="false" OC="false" P="false" />
// </Functions>
// </ASCOM>

ASCOM_ClientID = 0;
ASCOM_CallID = 0;
ASCOM_LastCallID = 0;
ASCOM_LockCallID = 0;

"abc_LoadplayerPosEventArgs" addPublicVariableEventHandler {
   private ["_array"];

   _array = _this select 1;

   _array spawn {
       if ((_this select 0 == "A") || (_this select 0 == "C" && !isDedicated)) then {
           (_this select 1) call abc_LoadplayerPos;
       };

       if (_this select 0 == "S" && isServer) then {
           (_this select 1) call abc_LoadplayerPos;
       };
   };
};

abc_LoadplayerPosServer = {
   if (isNil "_this") then { _this = []; };
   if (isServer) then {
       _this call abc_LoadplayerPos;
   }
   else {
       abc_LoadplayerPosEventArgs = ["S", _this];
       publicVariable "abc_LoadplayerPosEventArgs";
       abc_LoadplayerPosEventArgs = [];
   };
};


"abc_LoadPlayerWeaponEventArgs" addPublicVariableEventHandler {
   private ["_array"];

   _array = _this select 1;

   _array spawn {
       if ((_this select 0 == "A") || (_this select 0 == "C" && !isDedicated)) then {
           (_this select 1) call abc_LoadPlayerWeapon;
       };

       if (_this select 0 == "S" && isServer) then {
           (_this select 1) call abc_LoadPlayerWeapon;
       };
   };
};

abc_LoadPlayerWeaponServer = {
   if (isNil "_this") then { _this = []; };
   if (isServer) then {
       _this call abc_LoadPlayerWeapon;
   }
   else {
       abc_LoadPlayerWeaponEventArgs = ["S", _this];
       publicVariable "abc_LoadPlayerWeaponEventArgs";
       abc_LoadPlayerWeaponEventArgs = [];
   };
};



if (isServer) then {
   "ASCOM_AskForClientID" addPublicVariableEventHandler {
       private ["_unit"];

       _unit = _this select 1;
       ASCOM_AskForClientID = [];
       ASCOM_LastCallID = ASCOM_LastCallID + 1;
       ASCOM_ClientIDResponse = [_unit, ASCOM_LastCallID];
       publicVariable "ASCOM_ClientIDResponse";
   };

   ASCOM_ServerInitialized = true;
   publicVariable "ASCOM_ServerInitialized";
   ASCOM_Initialized = true;
}
else {
   "ASCOM_ClientIDResponse" addPublicVariableEventHandler {
       private ["_array"];

       _array = _this select 1;
       ASCOM_ClientIDResponse = [];

       if (player == (_array select 0)) then {
           ASCOM_ClientID = _array select 1;
           ASCOM_Initialized = true;
       };
   };

   waitUntil {!isNull player};
   ASCOM_AskForClientID = player;
   publicVariable "ASCOM_AskForClientID";
};

This works for me and players on my server to save most gear + pos,

First, i must say thank you to the OP as the DB is the only reason i wanted a Dayz port to A3 in the first place. Second, thank you everyone who went through the trials and tribulations to find different uses for this. I am trying to use this with my wasteland server, but when i run it and load the mission file, it tells me cannot find It cannot find iniDB/init.sqf. Then it turns me into a bird and says something like "Cannot Connect to the Positioning System". Any Ideas? I am fairly new to this but i am reading everyday learning more and more from trial/error, there is just some things i cannot learn without trying it myself though no matter how much reading i do. (eventually i am not learning anything, just looking at a page) I will take any help i can get as I REALLY would like to implement this. Thank you.

Share this post


Link to post
Share on other sites
Right to assist the bambies that gotten same confused as i have, This is how i got mine working in the end ;

Init.sqf

call compile preProcessFile "\iniDB\init.sqf";
call compile preProcessFile "Arma3functions.sqf";
execVM "load.sqf";
abc_LoadplayerPos = {
   private ["_loadpos"];
   _loadpos = _this select 0;
   _Profile = format["%1", getPlayerUID _loadpos];
   _Pos = [_Profile, "playerData", "position", "ARRAY"] call iniDB_read;
   _weaponadd = [_Profile, "playerData", "weapons", "ARRAY"] call iniDB_read;
_weaponadd1 = [_Profile, "playerData", "weapons1", "STING"] call iniDB_read;
   _itemsadd = [_Profile, "playerData", "magazines", "ARRAY"] call iniDB_read;
_vestadd = [_Profile, "playerData", "vest", "STING"] call iniDB_read;
_uniformadd = [_Profile, "playerData", "uniform", "STING"] call iniDB_read;
_helmetadd = [_Profile, "playerData", "headgear", "STING"] call iniDB_read;
_loadpos setpos _Pos;
for "_i" from 0 to (count _itemsadd) do {_loadpos addMagazine (_itemsadd select _i)};
for "_y" from 0 to (count _weaponadd) do {_loadpos addweapon (_weaponadd select _y)};
_loadpos addvest _vestadd;
_loadpos adduniform _uniformadd;
_loadpos addheadgear _helmetadd;
hint format["%1",_pos];
   // Code goes here!
};



if(isServer) then {
[] execVM "save.sqf";};

Load.sqf

player addbackpack "B_Bergen_sgg";
removeallweapons player;
removeuniform player;
removeheadgear player;
removevest player;
[player] call abc_LoadplayerPosServer;

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", "weapons", Weapons _x] call iniDB_write;
[_Profile, "playerData", "weapons1", SecondaryWeapon _x] call iniDB_write;
[_Profile, "playerData", "vest", vest _x] call iniDB_write;
[_Profile, "playerData", "uniform", uniform _x] call iniDB_write;
[_Profile, "playerData", "headgear", headgear _x] call iniDB_write;
[_Profile, "playerData", "items", items _x] call iniDB_write;
	};
} forEach allUnits;
}
};

and the Arma3functions - Generated file via using ASCOM Framework

// Do not edit this file!
// This file may only be edited by Engima's ASCOM Editor!
//
// <ASCOM version="1">
// <Prefix>abc_</Prefix>
// <Functions>
// <Function Name="LoadplayerPos" Params="loadpos" Ret="false" A="false" C="false" S="true" O="false" OC="false" P="false" />
// <Function Name="LoadPlayerWeapon" Params="weapon" Ret="false" A="false" C="false" S="true" O="false" OC="false" P="false" />
// </Functions>
// </ASCOM>

ASCOM_ClientID = 0;
ASCOM_CallID = 0;
ASCOM_LastCallID = 0;
ASCOM_LockCallID = 0;

"abc_LoadplayerPosEventArgs" addPublicVariableEventHandler {
   private ["_array"];

   _array = _this select 1;

   _array spawn {
       if ((_this select 0 == "A") || (_this select 0 == "C" && !isDedicated)) then {
           (_this select 1) call abc_LoadplayerPos;
       };

       if (_this select 0 == "S" && isServer) then {
           (_this select 1) call abc_LoadplayerPos;
       };
   };
};

abc_LoadplayerPosServer = {
   if (isNil "_this") then { _this = []; };
   if (isServer) then {
       _this call abc_LoadplayerPos;
   }
   else {
       abc_LoadplayerPosEventArgs = ["S", _this];
       publicVariable "abc_LoadplayerPosEventArgs";
       abc_LoadplayerPosEventArgs = [];
   };
};


"abc_LoadPlayerWeaponEventArgs" addPublicVariableEventHandler {
   private ["_array"];

   _array = _this select 1;

   _array spawn {
       if ((_this select 0 == "A") || (_this select 0 == "C" && !isDedicated)) then {
           (_this select 1) call abc_LoadPlayerWeapon;
       };

       if (_this select 0 == "S" && isServer) then {
           (_this select 1) call abc_LoadPlayerWeapon;
       };
   };
};

abc_LoadPlayerWeaponServer = {
   if (isNil "_this") then { _this = []; };
   if (isServer) then {
       _this call abc_LoadPlayerWeapon;
   }
   else {
       abc_LoadPlayerWeaponEventArgs = ["S", _this];
       publicVariable "abc_LoadPlayerWeaponEventArgs";
       abc_LoadPlayerWeaponEventArgs = [];
   };
};



if (isServer) then {
   "ASCOM_AskForClientID" addPublicVariableEventHandler {
       private ["_unit"];

       _unit = _this select 1;
       ASCOM_AskForClientID = [];
       ASCOM_LastCallID = ASCOM_LastCallID + 1;
       ASCOM_ClientIDResponse = [_unit, ASCOM_LastCallID];
       publicVariable "ASCOM_ClientIDResponse";
   };

   ASCOM_ServerInitialized = true;
   publicVariable "ASCOM_ServerInitialized";
   ASCOM_Initialized = true;
}
else {
   "ASCOM_ClientIDResponse" addPublicVariableEventHandler {
       private ["_array"];

       _array = _this select 1;
       ASCOM_ClientIDResponse = [];

       if (player == (_array select 0)) then {
           ASCOM_ClientID = _array select 1;
           ASCOM_Initialized = true;
       };
   };

   waitUntil {!isNull player};
   ASCOM_AskForClientID = player;
   publicVariable "ASCOM_AskForClientID";
};

This works for me and players on my server to save most gear + pos,

This works great! However it strips the player of weapons and clothing items on first login. is that by design or have I gone horribly wrong somewhere

Share this post


Link to post
Share on other sites

Hi,

I am trying to implement your addon to our wasteland project and when I start a server and I connect to it the logfile says

14:09:20 Mission 404Wasteland - Chernarus [v2.9a] read from directory.

14:09:20 Mission 404Wasteland - Chernarus [v2.9a] read from directory.

14:09:20 Mission 404Wasteland - Chernarus [v2.9a] read from directory.

14:09:20 Mission 404Wasteland - Chernarus [v2.9a] read from directory.

14:09:20 Mission 404Wasteland - Chernarus [v2.9a] read from directory.

14:09:20 Mission 404Wasteland - Chernarus [v2.9a] read from directory.

14:09:21 Mission 404Wasteland - Chernarus [v2.9a] read from directory.

14:09:21 Mission 404Wasteland - Chernarus [v2.9a] read from directory.

14:09:21 Mission 404Wasteland - Chernarus [v2.9a] read from directory.

14:09:21 Mission 404Wasteland - Chernarus [v2.9a] read from directory.

14:09:21 Mission 404Wasteland - Chernarus [v2.9a] read from directory

and nothing else really happens, it just keeps looping this.

Now im a total noob concerning scripting so im sure im doing something wrong :P Does this say anything to you and can you point out the problem perhaps?

thanks

Share this post


Link to post
Share on other sites

Great job mate, awesome bit of code. Im having a bit of a strange problem on the load however, when using it in conjunction with the set / getloadout code from Aeroson similar to your example at the start of this thread.

Everything is working as intended - it all saves correctly (everything is server run) and I am using exactly the same methods for my save / load as you have - however with large loadouts the array doesn't seem to be returning from the iniDB_read and the server report returns the following error :

String STR_EVAL_QUOTE not found

Error in expression <_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Gren>

Error position: <"1Rnd_HE_Gren>

Error

Error in expression <_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Gren>

Error position: <"1Rnd_HE_Gren>

Error

This is error appears to occur even before I call the setLoadout method and is being raised from the iniDB_read.

My actual load code is below :

_arr = ([_unitFileName, _sectionTitle, "loadout", "ARRAY"] call iniDB_read);

[_unit, _arr] spawn setLoadout;

The loadout section (which is generated by using the "getLoadout" function from my .ini file is :

loadout="[["ItemMap","ItemCompass","ItemWatch","ACRE_PRC148_UHF_ID_1","H_Cap_ion","Binocular"],"FHQ_M4A1_M203_TAN",["FHQ_M4_muzzle_snds_556_blk","FHQ_acc_LLM01L","FHQ_optic_ACOG"],"",[],"",[],"U_B_CombatUniform_mcam_tshirt",["SmokeShell","SmokeShell","SmokeShell","SmokeShell","SmokeShell"],"V_PlateCarrierGL_rgr",["1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","FHQ_30Rnd_556x45_Stanag_Tracer_Red","FHQ_30Rnd_556x45_Stanag_Tracer_Red","FHQ_30Rnd_556x45_Stanag_Tracer_Red","FHQ_30Rnd_556x45_Stanag_Tracer_Red","FHQ_30Rnd_556x45_Stanag_Tracer_Red","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","SmokeShell","SmokeShell","SmokeShell"],"B_Kitbag_cbr",["FHQ_optic_TWS3050","Medikit","FirstAidKit","FirstAidKit","FirstAidKit","FirstAidKit","FirstAidKit","FirstAidKit","FirstAidKit","FirstAidKit","FirstAidKit","FirstAidKit","NVGoggles","FHQ_30Rnd_556x45_Stanag_Tracer_Red","FHQ_30Rnd_556x45_Stanag_Tracer_Red","FHQ_30Rnd_556x45_Stanag_Tracer_Red","FHQ_30Rnd_556x45_Stanag_Tracer_Red","FHQ_30Rnd_556x45_Stanag_Tracer_Red","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","1Rnd_HE_Grenade_shell","SmokeShell","SmokeShell"],[["30rnd_556x45_stanag","1rnd_he_grenade_shell"],"",""],"FHQ_M4A1_M203_TAN","Single"]"

Any assistance you could offer up would be much appreciated - as I say for smaller loadouts it all seems to work great.

Cheers mate.

Share this post


Link to post
Share on other sites

Just to clarify how to install....

I put the @iniDB file in my/server ArmA 2 directory

I then add "call compile preProcessFile "\iniDB\init.sqf";" to my missions Init.sqf file even though there is no folder called iniDB which contains init.sqf

Is that correct? It just doesn't seem logical adding "\iniDB\init.sqf";" when there isn't a folder called that. There will be a folder called @iniDB but not iniDB.

Any help would be appreciated

Share this post


Link to post
Share on other sites

@iniDB is the mod folder. the path \iniDB\ on the other hand refers to the pbo inside the addons folder inside the @iniDB folder. so yea the server needs that line. and to avoid error messages for the clients due to them looking for the file, just add a server check like this.

if (IsServer) then {call compile preProcessFile "\iniDB\init.sqf";};

Share this post


Link to post
Share on other sites

Great addon, can see myself using this in future.

Perhaps it would be an idea to compile the functions using cfgFunctions in config.cpp for better security / implementation?

Share this post


Link to post
Share on other sites

So I do this:

Add @iniDB mod folder to my servers directory

Add the "if (IsServer) then {call compile preProcessFile "\iniDB\init.sqf";}; " to my mission init.sqf file

Then I am free to save/load variables?

Share this post


Link to post
Share on other sites
So I do this:

Add @iniDB mod folder to my servers directory

Add the "if (IsServer) then {call compile preProcessFile "\iniDB\init.sqf";}; " to my mission init.sqf file

Then I am free to save/load variables?

Depends a little bit on your setup.

I am using a dedicated server, so I run the following:

start arma3.exe -server -port=2302 -config=cfg\config.cfg -mod=@iniDB -world=Stratis

Client side I don't put any mod parameter at all.

I then used DukeRevengers code within my mission PBO.

Only thing now is the position is saving to @inidb/db , but its not loading or load.sqf is wrong somehow.

Yet to figure out why. If anyone has working setup and they can share what they have done, would be appreciated.

Share this post


Link to post
Share on other sites

I've hit a wall and can't get any further.

Dev, great work, when you get a chance, please post up a mission example, or if anyone else has this working and you can share what you have, much appreciated it will be.

Share this post


Link to post
Share on other sites

Thanks for the help guys :)

---------- Post added at 00:31 ---------- Previous post was at 00:30 ----------

I will try and implement this soon shinkicker, and if I have any joy with the saving/loading I will certainly give you the mission code

Share this post


Link to post
Share on other sites
Thanks for the help guys :)

---------- Post added at 00:31 ---------- Previous post was at 00:30 ----------

I will try and implement this soon shinkicker, and if I have any joy with the saving/loading I will certainly give you the mission code

Thanks mate.

eagledude4 gave me loads of help last night and we got quite far. Still hitting some issues which I will post up later (at work the moment away from my gaming PC).

Share this post


Link to post
Share on other sites

eagledude4, are you only loading the variables up at the start of the mission?

Share this post


Link to post
Share on other sites

@Jammy: Correct. And as for the data not being overwritten, iniDB doesn't allow square brackets in the first and second index of the write array.

Also, why does the below code not give my player magazines or weapons?

//Magazines
_Mags = ["Players", _cell, "Magazines", "ARRAY"] call iniDB_read;
{
_player addMagazine _x;
} forEach _Mags;

//Weapons
_Weaps = ["Players", _cell, "Weapons", "ARRAY"] call iniDB_read;
{
_player addWeapon _x;
} forEach _Weaps;

Edited by eagledude4

Share this post


Link to post
Share on other sites

@eagle, make sure the 'Magazines' and 'Weapons' are in the correct case. i.e magazines != Magazines

Share this post


Link to post
Share on other sites

I save them both as lowercase.

EDIT: I fixed the problem by sending the arrays to the client and have the ciient add the weapons/magazines instead of the server.

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  

×