Jump to content
Sign in to follow this  
Linker Split

Export text via script to a .txt file

Recommended Posts

Cool, thank you!

also, I'm trying to compile a function which ahs the following syntax:

name_func =
       {
       _car = _this select 0;
       if (condition) exitWith  {code};
       if (condition) exitWith  {code};
       if (condition) exitWith  {code};
       if (condition) exitWith  {code};
       };

I'm compiling using this code in my init.sqf:

call compile preprocessFileLineNumbers "nameofsqf.sqf";

Then, in the car script, I've added:

[vehicle] spawn name_func;

but its not working, so I think I'm failing to compile the function

Share this post


Link to post
Share on other sites
Guys I think that we have figured out how to get the variables ingame back after restart.

How did you get it fixed in the end? - be useful for people reading this thread to see what the solution was :)

Share this post


Link to post
Share on other sites
How did you get it fixed in the end? - be useful for people reading this thread to see what the solution was :)

A friend of mine is creating a little program that reads the info from the .vars file, writes them into the SQL. After that, when server restarts, it takes the data from the SQL and writes them down into a SQF that will be used to check for variables :D

Share this post


Link to post
Share on other sites
also, I'm trying to compile a function which ahs the following syntax:

That all looks correct. Where are you calling the car script from? from the vehicles init? It may just be a timing issue if so, as object inits are run before init.sqf, you may want to look at CfgFunctions and compile your script that way so your function is available straight away rather than compiling it from the init.sqf.

A friend of mine is creating a little program that reads the info from the .vars file, writes them into the SQL. After that, when server restarts, it takes the data from the SQL and writes them down into a SQF that will be used to check for variables

If your going to all that trouble you might aswell just use iniDB and save your variables that way. Above seems a little convoluted.

Edited by Larrow

Share this post


Link to post
Share on other sites

in my mission init.sqf there's:

call compile preprocessFileLineNumbers "DBSave\EP_fn_saveData.sqf";
//========CAR.SQF LOAD==========\\
[] execVM (DIR_S + "Car.sqf");

EP_fn_saveData.sqf is the function with the data inside of corse, while car.sqf is the script for spawning cars.

Inside this script, there's a check for the type of car, then the line

[_vehicle1,_nmr] spawn EP_fn_saveData;

where _vehicle1 is the create vehicle, and _nmr has been defined equal to 1 (other cars got 2, 3, 4...etc).

diag_log works till this line

Share this post


Link to post
Share on other sites

And EP_fn_saveData.sqf look like?..

EP_fn_saveData = {
   ///My Code
};

?

Share this post


Link to post
Share on other sites
And EP_fn_saveData.sqf look like?..
EP_fn_saveData = {
   ///My Code
};

?

it looks like this:

EP_fn_saveData = 
{
private ["_car","_nmbr"];

diag_log "EP_fn_saveData.sqf is about to be executed";
_car  = _this select 0;
_nmbr = _this select 1;

//Start saving position
if (_nmbr == 1) exitWith
{
	_xPos1 = ((getPosASL _car) select 0);		// X COORDINATES
	_yPos1 = ((getPosASL _car) select 1);		// Y COORDINATES
	_zPos1 = ((getPosASL _car) select 2);		// HEIGHT COORDINATES
	_typeOf = typeOf _car;
	_d = direction _car
	// SAVING ALL VARIABLES
	profileNameSpace setVariable [format["xPos%1",_nmbr],_xPos1];
	profileNameSpace setVariable [format["yPos%1",_nmbr],_yPos1];
	profileNameSpace setVariable [format["zPos%1",_nmbr],_zPos1];
	profileNameSpace setVariable [format["typeCar%1",_nmbr],_typeOf];
	profileNameSpace setVariable [format["dirCar%1",_nmbr],_d];
	saveProfileNameSpace;
	diag_log "EP_fn_saveData.sqf has finished executing";
};
};

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

SOLVED:

changed the code to:

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

EP_fn_saveData = 
{
private ["_car","_nmbr"];
diag_log "EP_fn_saveData.sqf start loading";
_car = _this select 0;
_nmbr = _this select 1;
_typeOf = typeOf _car;
_d = direction _car;
profileNameSpace setVariable [format["xPos%1",_nmbr],((getPosASL _car) select 0)];
profileNameSpace setVariable [format["yPos%1",_nmbr],((getPosASL _car) select 1)];
profileNameSpace setVariable [format["zPos%1",_nmbr],((getPosASL _car) select 2)];
profileNameSpace setVariable [format["typeCar%1",_nmbr],_typeOf];
profileNameSpace setVariable [format["dirCar%1",_nmbr],_d];
saveProfileNameSpace;
diag_log "EP_fn_saveData.sqf has finished executing";
};

Edited by Linker Split

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  

×