Jump to content
pliskin124

inidbi2 Help - Saving Player Location (Help with an Array)

Recommended Posts

Hi there,


Thank you for taking the time to look at my post.

 

I am trying to save the players location data into the idbi2 database. I have the Gear, Name, and UID all saving correctly, but for the life of me I cannot get the players location to save and  read. I keep getting the error "error type String, expected number" on the init.sqf line 13 the "player setPosATL [_location select 0, _location select 1, _location select 2];" section. - Any help would be most appreciated.

 

Init.sqf:

 

_clientID = clientOwner;
_UID = getPlayerUID player;
_name = name player;
_location = getPosATL player;
checkForDatabase = [_clientID, _UID, _name, _location];
publicVariableServer "checkForDatabase";

"loadData" addPublicVariableEventHandler
	{
	_gear = (_this select 1);
	_location = [_this select 0, _this select 1, _this select 2];
	player setUnitLoadout _gear;
	player setPosATL [_location select 0, _location select 1, _location select 2];
	};
};


initServer:

 

"checkForDatabase" addPublicVariableEventHandler
{
	private ["_data"];
	_data = (_this select 1);
	_clientID = (_data select 0);
	_UID = (_data select 1);
	_playerName = (_data select 2);
	_location = [_data select 0, _data select 1, _data select 2];
	
	_inidbi = ["new", _UID, _location] call OO_INIDBI;
	_fileExist = "exists" call _inidbi;
	
	if (_fileExist) then
	{
		hint "FILE DOES EXIST, GETTING DATA";
		null = [_UID, _clientID, _location] execVM "getData.sqf";
	}
	else
	{
		hint "FILE DOES NOT EXIST, CREATING DATABASE";
		null = [_clientID, _UID, _playerName, _location] execVM "createDatabase.sqf";
	};
};

"saveData" addPublicVariableEventHandler
{
	private ["_data"];
	_data = (_this select 1);
	_UID = (_data select 0);
	_gear = (_data select 1);
	_location = [_data select 0, _data select 1, _data select 2];
	
	_inidbi = ["new", _UID] call OO_INIDBI;	
	
	["write", ["Player Location", "Location", _location]] call _inidbi;
	["write", ["Player Gear", "Gear", _gear]] call _inidbi;
	hint "data saved";
};

 

getData.sqf

 

_UID = (_this select 0);
_clientID = (_this select 1);

_inidbi = ["new", _UID] call OO_INIDBI;

_gear = ["read", ["Player Gear", "Gear", []]] call _inidbi;
_location = ["read", ["Player Location", "Location", []]] call _inidbi;

loadData = _gear;
_clientID publicVariableClient "loadData";

saveData.sqf

 



{

_gear = getUnitLoadout player;
_location = getPosATL player;
saveData = [_UID, _gear, _location];
publicVariableServer "saveData";	


}


 

Share this post


Link to post
Share on other sites

As the error states, your issue lies in the "loadData" public variable event handler. Take another look at the addPublicVariableEventHandler page and see what "_this select 0" refers to. This is the name of the variable attached to the event handler, which is a string, and is exactly the error stated. I think when setting _location, you meant to select from _gear instead of _this and it should be something like:

"loadData" addPublicVariableEventHandler
	{
	_gear = (_this select 1);
	_location = [_gear select 0, _gear select 1, _gear select 2];
	player setUnitLoadout _gear;
	player setPosATL [_location select 0, _location select 1, _location select 2];
	};
};

As a side note, as long as you are selected from an array, there is no need to do this kind of stuff:

...etc
_location = [_gear select 0, _gear select 1, _gear select 2];
...
player setPosATL [_location select 0, _location select 1, _location select 2];
etc...

Instead you can simply do this:

_location = _gear select ?????;
player setPosATL _location;

EDIT: forgot to mention, if you are having issues like this, since there is no debugger it is incredibly useful to put this at the beginning of your functions:

systemChat str _this;

 

Share this post


Link to post
Share on other sites
1 hour ago, dreadedentity said:
Quote

This is the name of the variable attached to the event handler, which is a string, and is exactly the error stated. I think when setting _location, you meant to select from _gear instead of _this and it should be something like:


In regards to the "you meant to select from _gear instead of _this" part, 

My apologies, I believe that was sloppy coding on my part. The _gear function is supposed to save the _gear the player is wearing to the database under the "Player Gear" section, while the _location is meant to grab the coordinates of the player and save it under the "Player Location" part. I intended to make them two separate things but I believe I combined them if I understand your statement correctly.

 

Quote

As the error states, your issue lies in the "loadData" public variable event handler. Take another look at the addPublicVariableEventHandler page and see what "_this select 0" refers to.


If I understand it correctly, _this select 0 is selecting the first item in the array, which is what I intend to be the x coordinate, but I don't think I defined that correctly perhaps in the initial _location define?

Thank you for your help so far, I will add the systemChat str_this; and test out the code adjustments to see what effect they have

 

Share this post


Link to post
Share on other sites

After reading your response and reflecting further, I see in getData.sqf that you read the gear and location, I see that you set gear into the public variable, I do not see where you included location in the public variable. Maybe you meant it to be more like this:

_gear = ["read", ["Player Gear", "Gear", []]] call _inidbi;
_location = ["read", ["Player Location", "Location", []]] call _inidbi;

loadData = [_gear, _location];
_clientID publicVariableClient "loadData";

If so, then your public variable event handler could be like this:

"loadData" addPublicVariableEventHandler {
	_input = _this select 1;
	_gear = _input select 0;
	_location = _input select 1;
	player setUnitLoadout _gear;
	player setPosATL _location;
};
//but could be even shorter:
"loadData" addPublicVariableEventHandler {
	_input = _this select 1;
	player setUnitLoadout (_input select 0);
	player setPosATL (_input select 1);
};

 

Share this post


Link to post
Share on other sites
17 minutes ago, dreadedentity said:

After reading your response and reflecting further, I see in getData.sqf that you read the gear and location, I see that you set gear into the public variable, I do not see where you included location in the public variable. Maybe you meant it to be more like this:


_gear = ["read", ["Player Gear", "Gear", []]] call _inidbi;
_location = ["read", ["Player Location", "Location", []]] call _inidbi;

loadData = [_gear, _location];
_clientID publicVariableClient "loadData";

If so, then your public variable event handler could be like this:


"loadData" addPublicVariableEventHandler {
	_input = _this select 1;
	_gear = _input select 0;
	_location = _input select 1;
	player setUnitLoadout _gear;
	player setPosATL _location;
};
//but could be even shorter:
"loadData" addPublicVariableEventHandler {
	_input = _this select 1;
	player setUnitLoadout (_input select 0);
	player setPosATL (_input select 1);
};

 



Yes! I think that is what I was trying to achieve, thank you! That seems to have gotten me past the one hurdle, now I am receiving the following error from the createDatabase.sqf

"Error missing {
Error undefined viable in expression: _this
File createDatabase.sqf..., line 9"


 


_clientID = (_this select 0);
_UID = (_this select 1);
_playerName = (_this select 2);

_inidbi = ["new", _UID] call OO_INIDBI;

["write", ["Player Info", "Name", _playerName]] call _inidbi;
["write", ["Player Gear", "Gear", []]] call _inidbi;
["write", ["Player Location", "Location", []]]] call _inidbi;



The database appears to not be passing any data now too:
 

[Player Info]
Name=""Nomad""
[Player Gear]
Gear="[]"




 

Share this post


Link to post
Share on other sites

Doh!

Looks like that was a simple syntax error in the init.sqf, forgot the underscore behind _clientID 

Receiving a new error:

player setPosATL (_input select 1);
};
};
Error 0 elements provided, 3 expected
Error  undefined variable in expression: _this

File - init.sqf

Source: init.sqf - Line 13

Init.sqf:
 

systemChat str _this;

_clientID = clientOwner;
_UID = getPlayerUID player;
_name = name player;
_location = getPosATL player;
checkForDatabase = [_clientID, _UID, _name, _location];
publicVariableServer "checkForDatabase";

"loadData" addPublicVariableEventHandler {
	_input = _this select 1;
	player setUnitLoadout (_input select 0);
	player setPosATL (_input select 1);
};
};


Edit:

Solved, it was the systemChat str _this; line causing an issue.

Now receiving the following error from createDatabase.sqf (Also sorry for the spam, just trying to keep a record for anyone in the future who might come along to this thread)

"["player Location", "Location", []]]|#|] call_indibi;
Error Missing ;
File: createDatabase.sqf

createDatabase.sqf:

 


_clientID = (_this select 0);
_UID = (_this select 1);
_playerName = (_this select 2);

_inidbi = ["new", _UID] call OO_INIDBI;

["write", ["Player Info", "Name", _playerName]] call _inidbi;
["write", ["Player Gear", "Gear", []]] call _inidbi;
["write", ["Player Location", "Location", []]]] call _inidbi;


 

Edited by pliskin124

Share this post


Link to post
Share on other sites

Managed to clear the previous error 

 

"["player Location", "Location", []]]|#|] call_indibi;
Error Missing ;
File: createDatabase.sqf

By changing the line ["write", ["Player Location", "Location", []]] call _inidbi;

to: ["write", ["Player Location", "Location", 0]] call _inidbi;

No errors received, it is successfully writing to the db, the only issue now is none of the data seems to be compiling. 

Database:

[Player Info]
Name=""Nomad""
[Player Gear]
Gear="[]"
[Player Location]
Location="0"


I am certain this is some small error I'm making but I'm not sure where to go from here.
 

Share this post


Link to post
Share on other sites

I'm SO close!

The database is now reporting the location but not the gear. 

Here is what I have so far. I know I'm missing an integer somewhere or the _gear classname somewhere I just can't quite figure it out yet.

saveData.sqf: 



{
_gear = getUnitLoadout player;
_location = getPosATL player;
saveData = [_UID, _gear, _location];
publicVariableServer "saveData";	


}

getData.sqf:

 

_UID = (_this select 0);
_clientID = (_this select 1);

_inidbi = ["new", _UID] call OO_INIDBI;

_gear = ["read", ["Player Gear", "Gear", []]] call _inidbi;
_location = ["read", ["Player Location", "Location", []]] call _inidbi;

loadData = [_gear, _location];
_clientID publicVariableClient "loadData";


createDatabase.sqf


_clientID = (_this select 0);
_UID = (_this select 1);
_playerName = (_this select 2);
_gear = (_this select 1);
_location = (_this select 3);

_inidbi = ["new", _UID] call OO_INIDBI;

["write", ["Player Info", "Name", _playerName]] call _inidbi;
["write", ["Player Gear", "Gear", _gear]] call _inidbi;
["write", ["Player Location", "Location", _location]] call _inidbi;

initServer.sqf:

 

"checkForDatabase" addPublicVariableEventHandler
{
	private ["_data"];
	_data = (_this select 1);
	_clientID = (_data select 0);
	_UID = (_data select 1);
	_playerName = (_data select 2);
	_location = [_data select 3];
	
	_inidbi = ["new", _UID] call OO_INIDBI;
	_fileExist = "exists" call _inidbi;
	
	if (_fileExist) then
	{
		hint "FILE DOES EXIST, GETTING DATA";
		null = [_UID, _clientID, _location] execVM "getData.sqf";
	}
	else
	{
		hint "FILE DOES NOT EXIST, CREATING DATABASE";
		null = [_clientID, _UID, _playerName, _location] execVM "createDatabase.sqf";
	};
};

"saveData" addPublicVariableEventHandler
{
	private ["_data"];
	_data = (_this select 1);
	_UID = (_data select 0);
	_gear = (_data select 1);
	_location = [_data select 1];
	
	_inidbi = ["new", _UID] call OO_INIDBI;	
	
	["write", ["Player Location", "Location", _location]] call _inidbi;
	["write", ["Player Gear", "Gear", _gear]] call _inidbi;
	hint "data saved";
};

init.sqf:

 

_clientID = clientOwner;
_UID = getPlayerUID player;
_name = name player;
_location = getPosATL player;
checkForDatabase = [_clientID, _UID, _name, _location];
publicVariableServer "checkForDatabase";

"loadData" addPublicVariableEventHandler {
	_input = _this select 1;
	player setUnitLoadout (_gear select 0);
	player setPosATL (_location select 1);
};

 

Share this post


Link to post
Share on other sites

Eureka!

 

I now have the database posting the unit position, gear, and name and saving it as a UID file.

My only issue now is it is not reading or setting the position of the player from the database file.

 

Posting the completed edits for anyone interested:

init.sqf

_clientID = clientOwner;
_UID = getPlayerUID player;
_name = name player;
_gear = getUnitLoadout player;
_location = getPosATL player;
checkForDatabase = [_clientID, _UID, _name, _gear, _location];
publicVariableServer "checkForDatabase";

"loadData" addPublicVariableEventHandler {
	_input = _this select 1;
	player setUnitLoadout (_gear select 0);
	player setPosATL (_location select 1);
};

initServer.sqf

 

"checkForDatabase" addPublicVariableEventHandler
{
	private ["_data"];
	_data = (_this select 1);
	_clientID = (_data select 0);
	_UID = (_data select 1);
	_playerName = (_data select 2);
	_gear = (_data select 3);
	_location = [_data select 4];
	
	_inidbi = ["new", _UID] call OO_INIDBI;
	_fileExist = "exists" call _inidbi;
	
	if (_fileExist) then
	{
		hint "FILE DOES EXIST, GETTING DATA";
		null = [_UID, _clientID, _location] execVM "getData.sqf";
	}
	else
	{
		hint "FILE DOES NOT EXIST, CREATING DATABASE";
		null = [_clientID, _UID, _playerName, _gear, _location] execVM "createDatabase.sqf";
	};
};

"saveData" addPublicVariableEventHandler
{
	private ["_data"];
	_data = (_this select 1);
	_UID = (_data select 0);
	_gear = (_data select 1);
	_location = [_data select 1];
	
	_inidbi = ["new", _UID] call OO_INIDBI;	
	
	["write", ["Player Location", "Location", _location]] call _inidbi;
	["write", ["Player Gear", "Gear", _gear]] call _inidbi;
	hint "data saved";
};


createDatabase.sqf

 


_clientID = (_this select 0);
_UID = (_this select 1);
_playerName = (_this select 2);
_gear = (_this select 3);
_location = (_this select 4);

_inidbi = ["new", _UID] call OO_INIDBI;

["write", ["Player Info", "Name", _playerName]] call _inidbi;
["write", ["Player Gear", "Gear", _gear]] call _inidbi;
["write", ["Player Location", "Location", _location]] call _inidbi;


getData.sqf

 

_UID = (_this select 0);
_clientID = (_this select 1);

_inidbi = ["new", _UID] call OO_INIDBI;

_gear = ["read", ["Player Gear", "Gear", []]] call _inidbi;
_location = ["read", ["Player Location", "Location", []]] call _inidbi;

loadData = [_gear, _location];
_clientID publicVariableClient "loadData";

saveData.sqf

 



{
_gear = getUnitLoadout player;
_location = getPosATL player;
saveData = [_UID, _gear, _location];
publicVariableServer "saveData";	


}

 

Share this post


Link to post
Share on other sites

My assumption right now is that the issue lies with:

 

"loadData" addPublicVariableEventHandler {
	_gear = (_this select 1);
	_location = [_this select 0, _this select 1, _this select 2];
	player setUnitLoadout _gear;
	player setPosATL _location;
};

attempting to call an array from the database, but I'm not saving it as an array in 

 

["write", ["Player Info", "Name", _playerName]] call _inidbi;
["write", ["Player Gear", "Gear", _gear]] call _inidbi;
["write", ["Player Location", "Location", _location]] call _inidbi;


Not sure if that's off base or where to go from here. Going to fiddle with the _location parameter...

Share this post


Link to post
Share on other sites
3 minutes ago, dreadedentity said:

Does it give you an error?


I haven't quite figured out how to define the _location]] call _indibi as an array so I haven't checked the error on that, but at the moment I'm receiving:

 

_this select 1, _this select 2];

player setPosATL _...'

Error type Array, expected Bool

File: init.sqf... line 12

Share this post


Link to post
Share on other sites

Try:

hintSilent str variable;
or
systemChat str variable;

before your get to the line where the error is, that should give you some insight as to what's going on

Share this post


Link to post
Share on other sites
3 minutes ago, dreadedentity said:

Try:


hintSilent str variable;
or
systemChat str variable;

before your get to the line where the error is, that should give you some insight as to what's going on



Using the following init.sqf

 

player groupChat (format ["%1",_location]);
_clientID = clientOwner;
_UID = getPlayerUID player;
_name = name player;
_gear = getUnitLoadout player;
_location = getPosATL player;
checkForDatabase = [_clientID, _UID, _name, _gear, _location];
publicVariableServer "checkForDatabase";

"loadData" addPublicVariableEventHandler {
	_gear = (_this select 1);
	_location = [_this select 0, _this select 1, _this select 2];
	player setUnitLoadout _gear;
	player setPosATL _location;
};

it comes back with the reply "Any"

 

Not quite sure what to make of that, the original systemChat str _location command was throwing up errors

Share this post


Link to post
Share on other sites

I think maybe I see the issue here:

_gear = (_this select 1);
_location = [_this select 0, _this select 1, _this select 2];

In the public variable event handler, you have to use _this select 1 to get the value of the variable:

"loadData" addPublicVariableEventHandler {
	_loadDataValue = _this select 1; //take the whole value and store it in a variable, value is [_gear, _location]
	_gear = _loadDataValue select 0; //select the first element of the array to get gear, alternatively could use ((_this select 1) select 0)
	_location = _loadDataValue select 1; //select second element, alternatively could use ((_this select 1) select 1)
	player setUnitLoadout _gear;
	player setPosATL _location;
};

 

Share this post


Link to post
Share on other sites
46 minutes ago, dreadedentity said:

I think maybe I see the issue here:


_gear = (_this select 1);
_location = [_this select 0, _this select 1, _this select 2];

In the public variable event handler, you have to use _this select 1 to get the value of the variable:


"loadData" addPublicVariableEventHandler {
	_loadDataValue = _this select 1; //take the whole value and store it in a variable, value is [_gear, _location]
	_gear = _loadDataValue select 0; //select the first element of the array to get gear, alternatively could use ((_this select 1) select 0)
	_location = _loadDataValue select 1; //select second element, alternatively could use ((_this select 1) select 1)
	player setUnitLoadout _gear;
	player setPosATL _location;
};

 


Hmm... 

It seems to be producing the error code:

 

player setUnitLoadout _gear;
player setPosATL _location;

};

Error 0 elements provided, 3 expected

 

Source: Init.sqf

 

The side chat is still responding "any"

--------------------------

Edit:

 

Looks like that was due to me changing the line in createDatabase.sqf from:
["write", ["Player Location", "Location", _location]] call _inidbi;

 

 

Share this post


Link to post
Share on other sites

Edit:

 

Spoke too soon...

It's loading the gear now, but not the location.

 

Receiving the following error

"player setUnitLoadout _gear;
player setPosATL _location;
};

Error 1 elements provided, 3 expected

Source: Init.sqf line 14

If I am to interpret that correctly, it means it's expecting the x y z array? Not sure how to get it to define that

 

 

Share this post


Link to post
Share on other sites

Since I'm using inidbi2, I found the parameters for the read sequence...

 

Wondering if anyone can help me make sense of this.

 

   Function: read
    Usage : ["read", [_section, _key]] call _inidbi;

    Param: array
        string _section - name of sectrion containing the key
        string _key - name of key to read
    Output: value of key, if nothing is found return by default: false;

    You can set the default return value as follow (instead of false)
    ex:
    Usage : ["read", ["section", "key", "mydefaultvalueifnothingisfound"]] call _inidbi;
    Usage : ["read", ["section", "key", 0]] call _inidbi;
    Usage : ["read", ["section", "key", true]] call _inidbi;
    Usage : ["read", ["section", "key", ["mydefaultarray"]]] call _inidbi;

Of particular interest is the ["mydefaultarray"]]] I think may help?

Share this post


Link to post
Share on other sites

I've defined a new array in the createDatabase.sqf file...  which seems to take and populate the data onto the database, however I'm lost on how to call it correctly.


createDatabase.sqf

private _myArray = ["x","y","z"];
_clientID = (_this select 0);
_UID = (_this select 1);
_playerName = (_this select 2);
_gear = (_this select 3);
_location = (_this select 4);

_inidbi = ["new", _UID] call OO_INIDBI;

["write", ["Player Info", "Name", _playerName]] call _inidbi;
["write", ["Player Gear", "Gear", _gear]] call _inidbi;
["write", ["Player Location", "Location", _location,[_myArray]]] call _inidbi;

I tried changing the load data parameters to select each part of the array separately, not sure I'm doing it right

 

init.sqf

 

_clientID = clientOwner;
_UID = getPlayerUID player;
_name = name player;
_gear = getUnitLoadout player;
_location = getPosATL player;
checkForDatabase = [_clientID, _UID, _name, _gear, _location];
publicVariableServer "checkForDatabase";

"loadData" addPublicVariableEventHandler {
	_loadData = _this select 1; //take the whole value and store it in a variable, value is [_gear, _location]
	_gear = _loadData select 0; //select the first element of the array to get gear, alternatively could use ((_this select 1) select 0)
	_location = _loadData select 1; //select second element, alternatively could use ((_this select 1) select 1)
	player setUnitLoadout _gear;
	player setPosATL (_location select 0, _location select 1, _location select 2);
};


I keep receiving the error code

 

"player setPosATL (_location select 0, _location select 1, _location select 2); 
Error Missing )

init.sqf - Line 14

Share this post


Link to post
Share on other sites

I think the documentation is saying that it will return the value literally if no value is found, try finding your x,y,z coordinates and manually fill out the array (replace the 0's):

["read", ["Player Location", "Location", [0,0,0]]] call _inidbi;

Give this a try, I think this might be the break you need

Share this post


Link to post
Share on other sites
54 minutes ago, dreadedentity said:

I think the documentation is saying that it will return the value literally if no value is found, try finding your x,y,z coordinates and manually fill out the array (replace the 0's):


["read", ["Player Location", "Location", [0,0,0]]] call _inidbi;

Give this a try, I think this might be the break you need

 

I added this to the getData.sqf 
 

_location = ["read", ["Player Location", "Location", [1195.34,3407.94,30.00143909]]] call _inidbi;

but I'm still getting the following error

"player setUnitLoadout _gear;
player setPosATL _location;

};
File: Init.sqf Line 14 

Error 1 elements provided, 3 expected 

This is so frustrating, I sincerely appreciate you taking the time to stick with me on this, I'm sure you have better things to do. 

Updated SQF's for reference:

init.sqf

_clientID = clientOwner;
_UID = getPlayerUID player;
_name = name player;
_gear = getUnitLoadout player;
_location = getPosATL player;
checkForDatabase = [_clientID, _UID, _name, _gear, _location];
publicVariableServer "checkForDatabase";

"loadData" addPublicVariableEventHandler {
	_loadDataValue = _this select 1; //take the whole value and store it in a variable, value is [_gear, _location]
	_gear = _loadDataValue select 0; //select the first element of the array to get gear, alternatively could use ((_this select 1) select 0)
	_location = _loadDataValue select 1; //select second element, alternatively could use ((_this select 1) select 1)
	player setUnitLoadout _gear;
	player setPosATL _location;
};

getData.sqf

 

private _myArray = ["x","y","z"];
_UID = (_this select 0);
_clientID = (_this select 1);

_inidbi = ["new", _UID] call OO_INIDBI;

_gear = ["read", ["Player Gear", "Gear", []]] call _inidbi;
_location = ["read", ["Player Location", "Location", [1195.34,3407.94,30.00143909]]] call _inidbi;

loadData = [_gear, _location];
_clientID publicVariableClient "loadData";


createDatabase.sqf

 

private _myArray = ["x","y","z"];
_clientID = (_this select 0);
_UID = (_this select 1);
_playerName = (_this select 2);
_gear = (_this select 3);
_location = (_this select 4);

_inidbi = ["new", _UID] call OO_INIDBI;

["write", ["Player Info", "Name", _playerName]] call _inidbi;
["write", ["Player Gear", "Gear", _gear]] call _inidbi;
["write", ["Player Location", "Location", _location,[_myArray]]] call _inidbi;

initServer.sqf

 

"checkForDatabase" addPublicVariableEventHandler
{
	private ["_data"];
	_data = (_this select 1);
	_clientID = (_data select 0);
	_UID = (_data select 1);
	_playerName = (_data select 2);
	_gear = (_data select 3);
	_location = [_data select 4];
	
	_inidbi = ["new", _UID] call OO_INIDBI;
	_fileExist = "exists" call _inidbi;
	
	if (_fileExist) then
	{
		hint "FILE DOES EXIST, GETTING DATA";
		null = [_UID, _clientID, _location] execVM "getData.sqf";
	}
	else
	{
		hint "FILE DOES NOT EXIST, CREATING DATABASE";
		null = [_clientID, _UID, _playerName, _gear, _location] execVM "createDatabase.sqf";
	};
};


"saveData" addPublicVariableEventHandler
{
	private ["_data"];
	_data = (_this select 1);
	_UID = (_data select 0);
	_gear = (_data select 1);
	_location = [_data select 1];
	
	_inidbi = ["new", _UID] call OO_INIDBI;	
	
	["write", ["Player Location", "Location", _location]] call _inidbi;
	["write", ["Player Gear", "Gear", _gear]] call _inidbi;
	hint "data saved";
};



 

Share this post


Link to post
Share on other sites
28 minutes ago, pliskin124 said:

I sincerely appreciate you taking the time to stick with me on this, I'm sure you have better things to do. 

Yeah I don't mind, it reminds me of when I was making a system pretty much exactly like this years ago. I do wish you would make a github repo so I can download the mission and try it myself though

Share this post


Link to post
Share on other sites

To be honest I'm not sure how to make a github, but this is the test mission I'm testing the framework off of if you want to fiddle with it and see if you can get it to work:  https://mab.to/Y1W8HAPis
(myairbridge link to a .rar file)


If I can get this working I'll gladly share the main mission I'm developing it for with you, it's a multi-session operation type mission with some dynamic missions, headless client support, dynamic enemy occupation etc.
 

The addon for the database is here: You just put the @inidbi2 folder in the Arma 3 directory and copy the key in there to the keys folder should start working

 

Share this post


Link to post
Share on other sites

Just fiddling around with the code a bit, changed the init.sqf to:

 

"loadData" addPublicVariableEventHandler {
	_loadDataValue = _this select 1; //take the whole value and store it in a variable, value is [_gear, _location]
	_gear = _loadDataValue select 0; //select the first element of the array to get gear, alternatively could use ((_this select 1) select 0)
	_location = _loadDataValue select 1; //select second element, alternatively could use ((_this select 1) select 1)
	player setUnitLoadout _gear;
	player setPosATL ["read", ["Player Location", "Location", [1195.34,3407.94,30.00143909]]] call _inidbi;
};

No major change, but I did manage to get the error code to change from 2 elements to 3 elements provided... Clearly the code is expecting something I'm just not sure what.

player setPosATL ["read", [Player Location", "..."
Error 2 elements provided, 3 expected

Share this post


Link to post
Share on other sites

Trying this alternative method... getting a new error code.

 

_clientID = clientOwner;
_UID = getPlayerUID player;
_name = name player;
_gear = getUnitLoadout player;
_location = getPosATL player;
checkForDatabase = [_clientID, _UID, _name, _gear, _location];
publicVariableServer "checkForDatabase";

"loadData" addPublicVariableEventHandler {
	_loadDataValue = _this select 1; //take the whole value and store it in a variable, value is [_gear, _location]
	_gear = _loadDataValue select 0; //select the first element of the array to get gear, alternatively could use ((_this select 1) select 0)
	_coordinates = ["read", ["Player Location", "Location", []]]] call _inidbi; //select second element, alternatively could use ((_this select 1) select 1)
	player setUnitLoadout _gear;
	player setPosATL _coordinates;
};


My thought here is to define the variable _coordinates as reading the database file, then call that as the setPosATL but now I'm getting the following error code:

"["Player Location", "Location", []]]] call_inidbi;

player setUnitLoadout _...
Error Missing ;

Init.sqf - Line 12


Fixed, forgot to remove the extra ] 

Unfortunately it's not posting any errors, but it's also not doing anything either... which leaves me at a loss.

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

×