Jump to content
Sign in to follow this  
thedubl

initSever or init?

Recommended Posts

Hello, If I have a script that is run on the server, is it better to have the a script execVM in the initServer.sqf or the init.sqf with  if (isServer) then {}; wrapped around it? Does it even matter? I have seen it done a few ways now and was wondering if it even matters.

 

Travis

aka dubl

Share this post


Link to post
Share on other sites

I'd say it doesn't matter, but I'm sure smarter people will correct me. That if isserver is/was done because initserver.sqf didnt exist.

Share this post


Link to post
Share on other sites

I think it matters if you need to make sure certain files execute before/after each other. So splitting them up between the two could be problematic and harder to debug.

  • Like 1

Share this post


Link to post
Share on other sites

It doesn't matter too much, but it saves locality headache to avoid isServer checks where you can. 

 

There's just no reason to use init.sqf anymore except to load deprecated/obsolete/A2 code.

 

 

In reality, this is all the init structure is:

 

 

initFunctions.sqf

//--- Execute automatic scripts
if ((count (supportInfo "n:is3DEN") > 0 && {!is3DEN}) || (count (supportInfo "n:is3DEN") == 0)) then {
if (isserver) then {
[] execvm "initServer.sqf";
"initServer.sqf" call bis_fnc_logFormat;
};
 
//--- Run mission scripts
if !(isDedicated) then {
[player,_didJIP] execvm "initPlayerLocal.sqf";
[[[player,_didJIP],"initPlayerServer.sqf"],"bis_fnc_execvm",false,false] call bis_fnc_mp;
"initPlayerLocal.sqf" call bis_fnc_logFormat;
"initPlayerServer.sqf" call bis_fnc_logFormat;
};
0.90 call bis_fnc_progressloadingscreen;
 
//--- Call postInit functions
_fnc_scriptname = "postInit";
{
{
_time = diag_ticktime;
[_x,_didJIP] call {
private ["_didJIP","_time"];
["postInit",_this select 1] call (missionnamespace getvariable (_this select 0))
};
["%1 (%2 ms)",_x,(diag_ticktime - _time) * 1000] call bis_fnc_logFormat;
} foreach _x;
} foreach _this;
1.0 call bis_fnc_progressloadingscreen;
};

Share this post


Link to post
Share on other sites

Thanks for the replies.These few scripts aren't anyhting that need to be initailatzed immediately. I noticed that the resvered slots script somethimes allows the unreserverd player to get in a slot. I was think the maybe there is to much in the initServer that might be stepping on it. My though was to have it initalize in the init last. Can you put a sleep in a init to give it a second to initialize? Maybe that is dumb idea.  idk.

 

dubl

Share this post


Link to post
Share on other sites

initServer.sqf only gets run on the server, so no if (isServer) check is necessary (it really shouldn't be ever anyway, now that this functionality exsists)

Share this post


Link to post
Share on other sites

OK, got it. Well I just learned that my issue has more to do with patch 1.50. I thought maybe it was being stepped on during initialization, which is why I asked the original question. According to what Larrow pointed out in another post and what I read, it needs to have the -filepatching in the start up params and allowedfilepatch = 1; in the server.cfg since the script in question reads a txt file. Although it is still not working with the changes in the start up params and entry in the server.cfg, I think I am on the right path. Thanks for the replies.

 

UPDATE:
 

all is fixed...

https://forums.bistudio.com/topic/182520-script-to-lock-out-player-slots/

 

dubl

Share this post


Link to post
Share on other sites

Yes it matters depends on what script it is also say you have a script like this would need to go in the init server because the barrels our all server side so it would be init server not init you would want to initialize it over the server.

Share this post


Link to post
Share on other sites

Somewhat related question:

 

I inherited a mission over a year ago where it only contains an init.sqf file with a customscript.sqf to run other scripts. I would like to update that to the new standard of init.sqf - initserver.sqf - initplayerlocal.sqf.

 

Is there a place/section on the forums or a site to post code where other users can check/review it?

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  

×