cklymowsky 1 Posted May 6, 2018 HI All, I'm running a script in the InitServer.qsf that randomly generates sectors on the map, but this takes a few seconds to position them. During this time the map flashes and the CONTINUE button is enabled, but the sectors haven't finished being placed. HOW do I make the loading screen black and disable the CONTINUE button, until the script is finished? Thanks in advance Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted May 6, 2018 Use CfgFunctions with preInit instead of initServer.sqf, execution will be way faster and no need to mess around with anything else. Cheers Share this post Link to post Share on other sites
cklymowsky 1 Posted May 6, 2018 Thanks, I'm still working through the error messages, Does this also mean I also have to include the BIS functions that I call in my functions such as BIS_fnc_moduleSector; with {preInit = 1}; in the CfgFuntions? Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted May 6, 2018 1 hour ago, cklymowsky said: Thanks, I'm still working through the error messages, Does this also mean I also have to include the BIS functions that I call in my functions such as BIS_fnc_moduleSector; with {preInit = 1}; in the CfgFuntions? Try it out, I guess BIS functions are initialized before usermade CfgFunctions, if not simply call your functions with the postInit parameter, shouldn't make much of a difference. Cheers Share this post Link to post Share on other sites
Larrow 2800 Posted May 6, 2018 All functions from configs both base game/mods and description.ext are compiled before any that are flagged as preInit are called. So no need to include any functions other than your own definitions. 3 Share this post Link to post Share on other sites
cklymowsky 1 Posted May 6, 2018 HI All, Still having problems with preInit, and don't understand "Passed arguments are ["preInit"]". In my description.ext Quote class CfgFunctions { class BEAKS { class SetUp { file = "functions\SetUp"; class startSetUp {preInit = 1}; class sectorConfiguration {preInit = 1}; class findSuitableLocation {preInit = 1}; class createSector {preInit = 1}; }; }; }; startSetup calls sectorConfiguration that calls findSuitableLocation with: "_findSuitableLocation = [_location3D, _minDist, _maxDist, 10, 0, 0.25, 0, [], [[0,0,0],[0,0,0]]] call BIS_fnc_findSafePos;" ...and then calls createSector. But then I'm getting the following error, that is somehow related to preInit: Quote [BIS_fnc_findSafePos] Erro: type STRING, expected ARRAY, on index 0, in ["preinit,0,100,10,0.25,0,[],[[0,0,0],[0,0,0]]] fn_startSetUp.sqf Quote //Exit if we are not the server if !( isServer ) exitWith {}; createCenter playerSide; if (playerSide == WEST) then {AISide = EAST} else {AISide = WEST}; //_handle1 = addMissionEventHandler ["PreloadStarted",{titleCut ["", "BLACK FADED", 999]}]; //Select size with 1, 3, 5 or random number of Control Points _numberOfSectors = "Sectors" call BIS_fnc_getParamValue; if (_numberOfSectors == 4) then {[1, 3, 5] call BIS_fnc_selectRandom}; private ["_randomPosMapNoWater","_unssuccessful","_time"]; _time = time; _unssuccessful = FALSE; waitUntil { _randomPosMapNoWater = [nil, ["water"]] call BIS_fnc_randomPos; waitUntil {count _randomPosMapNoWater > 0}; _tower = objNull; _tower = "Land_Cargo_Tower_V1_No1_F" createVehicle _randomPosMapNoWater; _unssuccessful = [_numberOfSectors, _randomPosMapNoWater] call BEAKS_fnc_sectorConfiguration; if (_unssuccessful) then { { _x setVariable ["DefaultOwner","-1"]; deleteVehicle _x; } forEach ([TRUE] call bis_fnc_moduleSector); deleteVehicle _tower; }; (!_unssuccessful) }; fn_sectorConfiguration.sqf Quote //Exit if we are not the server if !( isServer ) exitWith {}; //params [["_numberOfSectors",1,[0]], "_randomPosMapNoWater",[0,0,0],[[]]]; params ["_numberOfSectors", "_randomPosMapNoWater"]; //hint format ["_numberOfSectors: %1 \n\n _randomPosMapNoWater: %2",_numberOfSectors, _randomPosMapNoWater]; _sectors = []; //Select size with 1, 3, 5 or random number of Control Points switch _numberOfSectors do { case 1 : {_sectors = ["1 CONTROL POINT"]}; case 3 : {_sectors = ["1 CONTROL POINT","2 CONTROL POINT","4 CONTROL POINT"]}; case 5 : {_sectors = ["1 CONTROL POINT","2 CONTROL POINT","3 CONTROL POINT","4 CONTROL POINT","5 CONTROL POINT"]}; }; private ["_randomDirection","_randomRadius","_location2D","_location3D","_unssuccessful"]; _unssuccessful = FALSE; _unssuccessful = [_randomPosMapNoWater, _sectors select 0] call BEAKS_fnc_findSuitableLocation; if (_unssuccessful) exitWith {TRUE}; //Select number and types of Bases with 1 , 2 or 3 pairs of either of A, M, and R _numberOfPairs = [1, 2, 3] call BIS_fnc_selectRandom; _numberOfPairs = 1; //WIP _pair1 = []; _pair1Array = []; switch _numberOfPairs do { case 1 : { _pair1 = [1,2,3] call BIS_fnc_selectRandom; switch _pair1 do { case 1 : {_pair1Array = ["Radio Tower 1","Radio Tower 2","Motor Pool 1","Armory 1"]}; case 2 : {_pair1Array = ["Motor Pool 1","Motor Pool 2","Radio Tower 1","Armory 1"]}; case 3 : {_pair1Array = ["Armory 1","Armory 2","Radio Tower 1","Motor Pool 1"]}; }; }; case 2 : { }; case 3 : { }; }; //Case with 1 Control Point: //With only one pair of either A, M, or R //randomize direction randomDirection _randomDirection = random 359; //_randomDirection randomRadius starting with r = 1000m by increments of 500m up to 2500m private ["_randomRadius"]; _randomRadius = [1000, 1500, 2000, 2500] call BIS_fnc_selectRandom; //insert either of the non-pair bases, randomly selected, at +80 to +100 degrees from direction at distance +/- 250m of radius _location2D = []; _location3D = []; _location2D = [_randomPosMapNoWater, _randomRadius + (round(random 500) -250), _randomDirection + 90 + (round(random 20) -10)] call BIS_fnc_relPos; _location3D = [_location2D select 0, _location2D select 1, 0]; _unssuccessful = [_location3D, _pair1Array select 2] call BEAKS_fnc_findSuitableLocation; if (_unssuccessful) exitWith {TRUE}; //create randomRadius starting with r = 1000m by increments of 500m up to 2500m _randomRadius = [1000, 1500, 2000, 2500] call BIS_fnc_selectRandom; //insert remaining of the-non pair bases, at +260 to +280 degrees from direction at distance +/- 250m of radius _nextDirection = 0; _createPairBasesFrom = []; _controlInCenter = ([0, 1] call BIS_fnc_selectRandom); switch _controlInCenter do { case 0 : {_createPairBasesFrom = _location3D; _nextDirection = _randomDirection + 90 + (round(random 20) -10)}; case 1 : {_createPairBasesFrom = _randomPosMapNoWater; _nextDirection = _randomDirection + 270 + (round(random 20) -10)}; }; _location2D = [_createPairBasesFrom, _randomRadius + (round(random 500) -250), _nextDirection] call BIS_fnc_relPos; _location3D = [_location2D select 0, _location2D select 1, 0]; _unssuccessful = FALSE; _unssuccessful = [_location3D, _pair1Array select 3] call BEAKS_fnc_findSuitableLocation; if (_unssuccessful) exitWith {TRUE}; //select randomAngle from +325 to +45 from direction _randomAngle = (round(random 90) -45); //create randomRadius starting with r = 1000m by increments of 500m up to 2500m _randomRadius = [1000, 1500, 2000, 2500] call BIS_fnc_selectRandom; //with 1 off-set to the end or with 1 in the centre _createPairBasesFrom = [_randomPosMapNoWater, _location3D] call BIS_fnc_selectRandom; //insert one of the pair bases at randomAngle at randomRadius with r = 1000m by increments of 500m up to 2500m _location2D = [_createPairBasesFrom, _randomRadius + (round(random 500) -250), _randomDirection + _randomAngle] call BIS_fnc_relPos; _location3D = [_location2D select 0, _location2D select 1, 0]; _unssuccessful =[_location3D, _pair1Array select 0, playerSide] call BEAKS_fnc_findSuitableLocation; if (_unssuccessful) exitWith {TRUE}; //randomly select whether the other base pair is at +180 or -180 degrees of the randomly selected angle called mirrorRandomAngle _mirrorRandomAngle = [1, 2] call BIS_fnc_selectRandom; if (_controlInCenter == 1) then {_mirrorRandomAngle = 1}; _newAngle = 0; switch _mirrorRandomAngle do { case 1 : { if (_randomAngle >= 0) then {_newAngle = _randomDirection + 180 - _randomAngle} else {_newAngle = _randomDirection + 180 + _randomAngle}; }; case 2 : {_newAngle = _randomDirection + 180; }; }; //insert one of the pair bases at randomirrorRandomAnglemAngle at same randomRadius of pair base _location2D = [_createPairBasesFrom, _randomRadius + (round(random 500) -250), _newAngle] call BIS_fnc_relPos; _location3D = [_location2D select 0, _location2D select 1, 0]; _unssuccessful =[_location3D, _pair1Array select 1, AISide] call BEAKS_fnc_findSuitableLocation; if (_unssuccessful) exitWith {TRUE}; FALSE fn_findSuitableLocation.sqf Quote //Exit if we are not the server if !( isServer ) exitWith {}; params ["_location3D","_base", ["_side","",[EAST,""]]]; private ["_findSuitableLocation","_minDist","_maxDist","_unssuccessful"]; _findSuitableLocation = []; _minDist = 0; _maxDist = 100; _unssuccessful = FALSE; waitUntil { _findSuitableLocation = [_location3D, _minDist, _maxDist, 10, 0, 0.25, 0, [], [[0,0,0],[0,0,0]]] call BIS_fnc_findSafePos; _minDist = _maxDist; _maxDist = _maxDist + 100; ( ({_x == 0} count _findSuitableLocation == 3) or (_maxDist == 500)) }; if ({_x == 0} count _findSuitableLocation == 3) exitWith {TRUE}; _base = [_findSuitableLocation, _base, _side] call BEAKS_fnc_createSector; FALSE fn_createSector.sqf Quote // If you are going to use it in public missions etc please just acknowledge Larrow and Bull_A. // https://forums.bohemia.net/forums/topic/181264-sector-module-scripting //Exit if we are not the server if !( isServer ) exitWith {}; params [["_pos",[0,0,0],[[],objNull,""]],["_baseName","",[""]],["_side","",[EAST,""]]]; //_pos = [_this,0,[],[[],objNull,""],3] call BIS_fnc_param; //_pos = _pos call BIS_fnc_position; _pos = _pos call BIS_fnc_position; //Create the sector logic _logic = (createGroup sideLogic) createUnit ["ModuleSector_F",_pos,[],0,"NONE"]; //ModuleSectorDummy_F ModuleSector_F _logic call BIS_fnc_moduleSector; //_logic call BEAKS_fnc_moduleSector; //Default setting, which are optional _logic setVariable ["Designation","1"]; _logic setVariable ["Name",_baseName]; _logic setVariable ["CostInfantry","1"]; _logic setVariable ["CostPlayers","2"]; _logic setVariable ["CostTracked","4"]; _logic setVariable ["CostWater","0"]; _logic setVariable ["CostWheeled","2"]; _logic setVariable ["DefaultOwner","-1"]; _logic setVariable ["CostAir","2"]; _logic setVariable ["OnOwnerChange",""]; _logic setVariable ["OwnerLimit","0"]; _logic setVariable ["ScoreReward","0"]; _logic setVariable ["TaskDescription",""]; _logic setVariable ["TaskOwner",""]; _logic setVariable ["TaskTitle",""]; //Set the sides for the sector _logic setVariable ["sides",[ east, west ]]; //Wait until sector is initialised waitUntil { !isNil { _logic getVariable [ "finalized", nil ] } && { !( _logic getVariable [ "finalized", true ] ) } }; //hint format ["Designation: %1 \n\n Name: %2",_logic getVariable "Designation", _logic getVariable "Name"]; //A size for the trigger _trgSize = 25; //Set the trigger size on the sector _logic setVariable [ "size", _trgSize ]; //Make the module update its trigger [ _logic, [], true, "area" ] call bis_fnc_moduleSector; //[ _logic, [], true, "area" ] call BEAKS_fnc_moduleSector; //Unfortunately the sector has not been written to also update its marker so.. //Get the modules trigger _trg = ( _logic getVariable "areas" ) select 0; //Get the triggers marker _mrk = ( _trg getVariable "markers" ) select 0; //Update the markers size _mrk setMarkerSize [ _trgSize, _trgSize ]; _mrk setMarkerAlpha 1; if (typeName _side == "SIDE") then { [ _logic, _side ] call BIS_fnc_moduleSector; //[ _logic, _side ] call BEAKS_fnc_moduleSector; if (_side == playerSide) then { _mg = createGroup playerSide; _mp = _mg createUnit ['B_Soldier_F',[0,0,0],[],0,'NONE']; selectPlayer _mp; player setPosATL [(_pos) select 0, ((_pos) select 1) + 35,0]; }; }; Share this post Link to post Share on other sites
Larrow 2800 Posted May 6, 2018 Just the fact that you have your functions defined under CfgFunctions means your functions are compiled and ready to use. To preInit a function means to also run that function pre initialization of the mission . So of course you dont want to run all your functions individually, which is what is happening with how you have it set up (each one being flagged as preInit). I've only had a very quick scan over your code and I actually think you may need postInit as it looks like you have some reliance on mission objects that will not have yet initialised properly if using preInit. Any function run using either preInit or postInit is passed as parameter 0 the string relating to the init type so "preInit" or "postInit" I would look into using postInit along with BIS_fnc_startLoadingScreen so as your functions run at full speed after the mission is initialized but before the briefing is displayed/anyone is spawned into the mission. Maybe when I'm back on my main PC I can help you further but just typing this on my HTPC via on screen keyboard was a PITA. Share this post Link to post Share on other sites
cklymowsky 1 Posted May 7, 2018 2 hours ago, Larrow said: Just the fact that you have your functions defined under CfgFunctions means your functions are compiled and ready to use. To preInit a function means to also run that function pre initialization of the mission . So of course you dont want to run all your functions individually, which is what is happening with how you have it set up (each one being flagged as preInit). I've only had a very quick scan over your code and I actually think you may need postInit as it looks like you have some reliance on mission objects that will not have yet initialised properly if using preInit. Any function run using either preInit or postInit is passed as parameter 0 the string relating to the init type so "preInit" or "postInit" I would look into using postInit along with BIS_fnc_startLoadingScreen so as your functions run at full speed after the mission is initialized but before the briefing is displayed/anyone is spawned into the mission. Maybe when I'm back on my main PC I can help you further but just typing this on my HTPC via on screen keyboard was a PITA. Ok Thanks Larrow, this worked... I went with the changes below...I suppose it can only have one function in either pre or post Init. preInit was generating errors as you mentioned perhaps do to something not being initialized, however I only have 2 soldiers saved on the map, but I don't have them included in the script? description. ext Quote class CfgFunctions { class BEAKS { class SetUp { file = "functions\SetUp"; class startSetUp {postInit = 1}; // {preInit = 1}; causes errors class createSector {}; // {postInit = 1}; can only run one function with either pre or post init class sectorConfiguration {}; // {postInit = 1}; class findSuitableLocation {}; // {postInit = 1}; }; }; }; fn_startSetUp.sqf Quote //Exit if we are not the server if !( isServer ) exitWith {}; ["myLoadingScreen", "Loading… wait for mission!"] call BIS_fnc_startLoadingScreen; createCenter playerSide; if (playerSide == WEST) then {AISide = EAST} else {AISide = WEST}; //_handle1 = addMissionEventHandler ["PreloadStarted",{titleCut ["", "BLACK FADED", 999]}]; //Select size with 1, 3, 5 or random number of Control Points _numberOfSectors = "Sectors" call BIS_fnc_getParamValue; if (_numberOfSectors == 4) then {[1, 3, 5] call BIS_fnc_selectRandom}; private ["_randomPosMapNoWater","_unssuccessful","_time"]; _time = time; _unssuccessful = FALSE; waitUntil { _randomPosMapNoWater = [nil, ["water"]] call BIS_fnc_randomPos; waitUntil {count _randomPosMapNoWater > 0}; _tower = objNull; _tower = "Land_Cargo_Tower_V1_No1_F" createVehicle _randomPosMapNoWater; _unssuccessful = [_numberOfSectors, _randomPosMapNoWater] call BEAKS_fnc_sectorConfiguration; if (_unssuccessful) then { { _x setVariable ["DefaultOwner","-1"]; deleteVehicle _x; } forEach ([TRUE] call bis_fnc_moduleSector); deleteVehicle _tower; }; (!_unssuccessful) }; "myLoadingScreen" call BIS_fnc_endLoadingScreen; Share this post Link to post Share on other sites
Larrow 2800 Posted May 7, 2018 8 hours ago, cklymowsky said: I suppose it can only have one function in either pre or post Init No you can have as many as you like. Its just the fact that you do not need to, you have a function (fn_startSetup) that calls another function fn_sectorConfiguration that calls another etc etc. What you where doing by making them all preInit was calling them all at the same time, which does not make sense for your setup as one function relies on another. E.g for instance it would be similar to doing this in the init.sqf [ "preInit" ] call BEAK_fnc_startSetup; [ "preInit" ] call BEAK_fnc_createSector; [ "preInit" ] call BEAK_fnc_sectorConfiguration [ "preInit" ] call BEAK_fnc_findSuitableLocation; You would never consider this to work when your functions rely on each other to work properly. Share this post Link to post Share on other sites