daza 36 Posted October 18, 2017 I'm making a sector control mission and the capturing sectors works fine. No probs there. What i want to is set up a trigger to end the game if blufor wins by capturing all the sectors. I'm using boolean variables to become true when blufor captures a sector eg. alpha sector variable sectorAlphaBlue is set via sectorAlphaBlue = true. In my init file i have sectorAlphaBlue=false; In the trigger that is with the Alpha sector that has to be captured if blufor is present in the activation i have: sectorAlphaBlue=true; publicvariable "sectorAlphaBlue"; My test trigger to see if this is working; Trigger with none none set up and in the activation: sectorAlphaBlue this just displays a hint and plays a music track as a test that this is working. What happens when i run the mission in MP mode....the music starts to play right at the start and the hint appears, some how my variable becomes true! My blufor unit is no where near the trigger around the sector area, there is no blufor units near the trigger in sector alpha or bravo sector . Why is this variable becoming true at the start? init sets it to false. Is there an easier way to have the game end when all zones are captured? which leads to my final question below.. Also as another question, you can set Size Reward for capturing a zone in the sector module, what built-in variable is this? just wondering if i could instead have the game end when one side gets so many points from capturing. Share this post Link to post Share on other sites
pierremgi 4623 Posted October 18, 2017 Probably a trigger initialization. You can add blufor present and on act: this && sectorAlphaBlue but, you don't need any trigger. Use the "expression field" of the module with: _this spawn {waituntil {sleep 2; (_this select 1) == west}; "SideScore" call BIS_fnc_endMissionServer} That's for one specific sector. You can use this kind of code to set variables then check if all variables are true for a final success. Add in init.sqf: sectorsWon = 0; then on each modules, let say you have 4 of them: _this spawn { while {true} do { waituntil {sleep 2; (_this select 1) == west}; sectorsWon = sectorsWon +1; waituntil {sleep 2; (_this select 1) != west}; sectorsWon = sectorsWon -1; } }; if (sectorsWon == 4) then { "SideScore" call BIS_fnc_endMissionServer}; Share this post Link to post Share on other sites
pierremgi 4623 Posted October 18, 2017 I found another way to check if blufor have won all sectors: count (true call BIS_fnc_moduleSector) == west call Bis_fnc_moduleSector Share this post Link to post Share on other sites
Midnighters 152 Posted October 18, 2017 I believe the sector modules store a "Owner" variable containing a side iirc, but the above works the best. Share this post Link to post Share on other sites
Larrow 2731 Posted October 18, 2017 4 hours ago, daza said: In the trigger that is with the Alpha sector that has to be captured if blufor is present in the activation i have Are you saying here that in the trigger that defines the sectors area you are settings its activation as Blufor present? If so the sector modules code resets its triggers activation to ANY PRESENT when it initialises. The variable BIS_fnc_moduleSector_sectors holds all sectors in the mission so you could do something like.. //initServer.sqf { //Add script EH, this is the same as filling the expression in the sector modules attributes [ _x, "ownerChanged", { params[ "_logic", "_owner", "_ownerOld" ]; //If the sector has been captured by west if ( _owner isEqualTo west ) then { //Get all mission sectors _allSectors = missionNamespace getVariable [ "BIS_fnc_moduleSector_sectors", [] ]; //If they are all owned by west if ( { _x getVariable [ "owner", sideUnknown ] isEqualTo west }count _allSectors isEqualTo count _allSectors ) then { //End the mission [ "SideScore" ] call BIS_fnc_endMissionServer; }; }; } ] call BIS_fnc_addScriptedEventHandler; }forEach ( missionNamespace getVariable [ "BIS_fnc_moduleSector_sectors", [] ] ); No loop needed, each time a sector is captured by West all other sectors will be checked and if they are all currently owned by West it will end the mission. Share this post Link to post Share on other sites
pierremgi 4623 Posted October 18, 2017 [] spawn { waituntil {sleep 2; count (true call BIS_fnc_moduleSector) == west call Bis_fnc_moduleSector}; "SideScore" call BIS_fnc_endMissionServer }; Share this post Link to post Share on other sites
daza 36 Posted October 18, 2017 57 minutes ago, pierremgi said: [] spawn { waituntil {sleep 2; count (true call BIS_fnc_moduleSector) == west call Bis_fnc_moduleSector}; "SideScore" call BIS_fnc_endMissionServer }; Thanks for your replies guys. I will try the simplest solution first. Added that to the init.sqf and it works great! thanks alot! I will add another one for opfor. Cheers! Share this post Link to post Share on other sites
pierremgi 4623 Posted October 18, 2017 27 minutes ago, daza said: Thanks for your replies guys. I will try the simplest solution first. Added that to the init.sqf and it works great! thanks alot! I will add another one for opfor. Cheers! I omit: initServer.sqf is sufficient enough. No need to run that on each PCs. Share this post Link to post Share on other sites
daza 36 Posted October 18, 2017 1 minute ago, pierremgi said: I omit: initServer.sqf is sufficient enough. No need to run that on each PCs. Oh i need to use initServer.sqf for more reliable results in MP? is that more for dedicated servers or will work just as well for self-hosted MP? ive always used init.sqf but if initServer.sqf is better to use for MP missions then i will go with that. Share this post Link to post Share on other sites
pierremgi 4623 Posted October 18, 2017 initServer.sqf runs only on server. init.sqf runs on server + clients. initPlayerLocal.sqf runs when player joins the game. You need to make these differences if you want to script something consistent in MP. In this case, there is no need to check module sector and trigger a global end on each PCs, with BIS_fnc_endMissionServer. Server is the good place for that. Share this post Link to post Share on other sites
daza 36 Posted October 19, 2017 Thanks for all your help pierremgi everything is running smoothly. Share this post Link to post Share on other sites