Jump to content
Sign in to follow this  
Tankbuster

init.sqf runs at different times server/client

Recommended Posts

I'm not entirely sure how I should phrase this...

It seems that init.sqf runs at different times during mission start.. ie, it runs much earlier on the server than it does on the client.

Also, when it runs on the server, it doesn't have any of the variables from parameters.

I don't know if the effects of this are serious, or if they all sort themselves out magically before the mission gets underway proper, but it does seem a bit odd. In my mission, for example, init.sqf runs on the client 69 seconds later than it does on the client, yet has none of the mission parameters defined.

Edited by Tankbuster

Share this post


Link to post
Share on other sites

It seems that init.sqf runs at different times during mission start.. ie, it runs much earlier on the server than it does on the client.

I could be wrong, but it could be for the loading time of the mission

Share this post


Link to post
Share on other sites

it does take around a minute for the client to download the mission file, if that's what you mean.

But if that's the case, given the init.sqf is common to both server and client, why isn't it's server execution waiting until the first client has downloaded the mission file and is able to run init.sqf concurrently?

Share this post


Link to post
Share on other sites

So that public variables are common to both client and server.

Also, it's odd that the params array doesn't exist on the server when init.sqf runs. As far as I can see, this has only been happening this way since 1.44

Edited by Tankbuster

Share this post


Link to post
Share on other sites
So that public variables are common to both client and server.

Not quite sure what do you mean by this.

Share this post


Link to post
Share on other sites

It seems natural to me that a file that runs on both server and clients should do that at the same time. Let me ask you this then - are there any benefits to having it not doing so?

Share this post


Link to post
Share on other sites

why the server should wait...as for the jip player, each machine runs its init.sqf.

Share this post


Link to post
Share on other sites

With introduction of initServer and initPlayerLocal I no longer see a need for init.sqf at all.

For public variables just use publicVariable 'myvar', or missionNamespace setVariable.

Using init.sqf I believe just causes unnecessary locality headaches

Share this post


Link to post
Share on other sites

It's not designed to be a sync mechanism. Init.sqf is just a list of stuff to do at the start of a mission. The timing depends purely on the machine running it; slower computer might run the file much later than server or other client(s). This mean, if you require some kind of sync between server and clients, then make clients wait for the server.

if isserver

myPub = 1234;

publicvariable "myPub"

if !isserver

waituntil !isnil "myPub"

Share this post


Link to post
Share on other sites

All fair points and they are taken onboard, thank you. I should move stuff from init.sqf to the local inits.

Perhaps I'm not asking the right question. :) When init.sqf runs on the server before a player joins, the init.sqf assumes the default values from the description.ext parameters. When it runs on the client, the player has had a chance to login as admin and make changes to the parameters.

So any parameters that affect server side stuff are ignored. This is new behaviour, before 1.44, this didn't happen.

Share this post


Link to post
Share on other sites
All fair points and they are taken onboard, thank you. I should move stuff from init.sqf to the local inits.

Perhaps I'm not asking the right question. :) When init.sqf runs on the server before a player joins, the init.sqf assumes the default values from the description.ext parameters. When it runs on the client, the player has had a chance to login as admin and make changes to the parameters.

So any parameters that affect server side stuff are ignored. This is new behaviour, before 1.44, this didn't happen.

It could simply be a bug, there is even a ticket on FT about paramsArray not being available at preInit.

Share this post


Link to post
Share on other sites

Is this this one you refer to KK?

http://feedback.arma3.com/view.php?id=18281

I'm not at my main PC now so I'll have to go back and check if this ticket does accurately describe my problem.

---------- Post added at 09:48 ---------- Previous post was at 09:34 ----------

Or perhaps this one. :) This explicity talks about it being post 1.44

http://feedback.arma3.com/view.php?id=24051&nbn=8

I too have started to create a workaround like other posters in that ticket, but hopefully, if it ius a bug, it'll get fixed

Share this post


Link to post
Share on other sites

Yes, that's close enough. There seems to be a few duplicates as well. I'll vote them all up

Thanks everyone and especially KK.

Share this post


Link to post
Share on other sites
http://feedback.arma3.com/view.php?id=24007 this one and there is internal ticket for it, thats all I know.

I dont understand this, am i doing something different/wrong? I dont see this behavior.

These are the results i get from stable - productVersion ["Arma 3","Arma3",144,130654,"Stable",false] which is what that ticket states.

Results from starting mission as adimin on a dedicated server.

Unit inits - spawning a global function defined within a preinit
//machine - call type : unit @ time - paramsArray value
"Client - Unit Init : B Alpha 1-1:1 (Dev) @ 0 - [1,11]"
"Client - Unit Init : B Alpha 1-2:1 REMOTE @ 0 - [1,11]"

Description.ext params function calls
//machine - param call type : passed value @ time - paramsArray value
"Client - function : [1] @ 0 - [1,11]"
"Server - function : [1] @ 0 - [1,11]"

Description.ext params file calls
//machine - param call type : passed value @ time - paramsArray value
"Server - file : [11] @ 0 - [1,11]"

Description.ext CfgFunctions preinit calls
//machine - preInit function : passed value @ time - paramsArray value
"Client - PreInitfunction : ["preInit"] @ 0 - nil"
"Server - PreInitfunction : ["preInit"] @ 0 - [1,11]"

The only time i get a nil paramsArray is from a preInit function on the client.

What is also weird from those results is that i never get a unit init from the server :/

description.ext

enabledebugconsole = 2;
respawn = 3;
respawnOnStart = 1;
respawnDelay = 1;

class CfgFunctions
{
class LARs
{
	class myCategory
	{
		class testFunction {
			file = "testFunction.sqf";
		};
		class PreInitFunction {
			file = "PreInitFunction.sqf";
			preinit = 1;
		};
	};
};
};


class Params
{

class myValue1
{
	title = "myValue1";
	texts[] = {"opt1","opt2","opt3","opt4"};
	values[] = {1,2,3,4};
	default = 1;
	function = "LARs_fnc_testFunction"; //Function is called when a machine connects inculding JIP, selected value is passed as an argument
		isGlobal = 1; //1 is called when anyone connects server or client (server only connects at initial mission start)/ 0 only called on the server (server only connects at initial mission start)
};
class myValue2
{
	title = "myValue2";
	texts[] = {"opt11","opt12","opt13","opt14"};
	values[] = {11,12,13,14};
	default = 11;
	file = "testFile.sqf"; //Script is called on server when player joins, only at initial mission start (not called for JIP)
};
};

testFunction.sqf

h = _this spawn {

_msg = format["function : %1 @ %2 - %3", _this, time, if !( isNil "paramsArray" ) then  [ { paramsArray }, { "nil" } ] ];

if (isServer) then {
	_msg = "Server - " + _msg;
};
if (!isServer) then {
	_msg = "Client - " + _msg;
};

sleep 5;
[ _msg, "diag_log", true ] call BIS_fnc_MP;

};

testFile.sqf

h = _this spawn {

_msg = format["file : %1 @ %2 - %3", _this, time, if !( isNil "paramsArray" ) then  [ { paramsArray }, { "nil" } ] ];

if (isServer) then {
	_msg = "Server - " + _msg;
};
if (!isServer) then {
	_msg = "Client - " + _msg;
};

sleep 5;
[ _msg, "diag_log", true ] call BIS_fnc_MP;
};

preInitFunction

h = _this spawn {

unitInitMsg = {

	_who = "undefined";
	if ( isServer ) then {
		_who = "Server";
	};
	if ( !isServer ) then {
		_who = "Client";
	};

	_msg = format["%1 - Unit Init : %2 @ %3 - %4", _who, _this, time, if !( isNil "paramsArray" ) then  [ { paramsArray }, { "nil" } ] ];

	sleep 5;
	[ _msg, "diag_log", true ] call BIS_fnc_MP;
};



_msg = format["PreInitfunction : %1 @ %2 - %3", _this, time, if !( isNil "paramsArray" ) then  [ { paramsArray }, { "nil" } ] ];

if (isServer) then {
	_msg = "Server - " + _msg;
};
if (!isServer) then {
	_msg = "Client - " + _msg;
};

sleep 5;
[ _msg, "diag_log", true ] call BIS_fnc_MP;

};

Share this post


Link to post
Share on other sites

Not fixed in the 1.48 update. :(

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  

×