chaoticgood 11 Posted September 18, 2013 Hello my script doesn't work for people who JIP. It works for people who join the game at the start. In the editor, I have a trigger set to activate by anyone and fire only once. In the trigger's activation field I have sp1 = [trigger1,"marker1"] spawn triggerLogic1; This is accompanied by a marker to show where the capture area is. Here is the init file if(isDedicated or isServer)then { execVM "captureFunctions.sqf"; }; captureFunctions.sqf: triggerLogic1 = { hint "triggerLogic1 spawned"; sleep 3; _trigger = _this select 0; //The trigger in the editor _marker = _this select 1; //The Marker in the editor _timerWest = 0; //Starts the timer at 0 _timerEast = 0; _timerResistance = 0; _timerLimit = 30; //Amount of time needed to capture the area _currentOwner = "civ";//The default owner while{true}do { sleep 1; _unitArray = list _trigger; //Get a list of all players in the trigger area then split them according to their side _westCount = west countSide _unitArray; _eastCount = east countSide _unitArray; _resistanceCount = resistance countSide _unitArray; waitUntil{(_westCount >=1 && !(_currentOwner == "west")) || (_eastCount >=1 && !(_currentOwner == "east")) || (_resistanceCount >=1 && !(_currentOwner == "resistance")) };//Pauses the loop until someone who can capture the area has entered i.e not someone who currently owns it if(_currentOwner != "west")then{ if(_westCount > _eastCount && _westCount > _resistanceCount)then{_timerWest = _timerWest + 1;}; //Check which side has the most players in the area and increase their capture progress }; if(_currentOwner != "east")then{ if(_eastCount > _westCount && _eastCount > _resistanceCount)then{_timerEast = _timerEast + 1;}; }; if(_currentOwner != "resistance")then{ if(_resistanceCount > _westCount && _resistanceCount > _eastCount)then{_timerResistance = _timerResistance + 1;}; }; if(_timerWest == _timerLimit)then{_marker setMarkerColor "ColorBlue";_timerWest = 0;_timerEast = 0;_timerResistance = 0;_currentOwner = "west";};//Once the capture progress reaches the limit, the area now becomes theirs. if(_timerEast == _timerLimit)then{_marker setMarkerColor "ColorRed";_timerWest = 0;_timerEast = 0;_timerResistance = 0;_currentOwner = "east";}; if(_timerResistance == _timerLimit)then{_marker setMarkerColor "ColorGreen";_timerWest = 0;_timerEast = 0;_timerResistance = 0;_currentOwner = "resistance";}; hint format ["West Count:%1 East Count: %2 Resistance Count: %3 \nWest Timer: %4 East Timer: %5 Resistance Timer: %6 \nCurrent Owner: %7",_westCount,_eastCount,_resistanceCount,_timerWest,_timerEast,_timerResistance,_currentOwner]; }; }; Share this post Link to post Share on other sites
chaoticgood 11 Posted September 19, 2013 (edited) Ok, I think I've found the problem. I have an idea but I need someone to tell me how to broadcast those hint messages in my script to the clients, as of now they run on the server, which isn't very useful as I can't see them. Any idea how? Thanks Edited September 19, 2013 by chaoticgood Share this post Link to post Share on other sites
Larrow 2822 Posted September 19, 2013 The problem is your waitUntil, your script gets stuck here because the trigger list is never getting re-evaluated so the count of anything in the trigger never changes. Quick fix including hint via public variable. init.sqf if ( isServer ) then { execVM "captureFunctions.sqf"; }; if ( !isDedicated ) then { waitUntil{!isNull player}; "hstring" addPublicVariableEventHandler { hint (_this select 1); }; }; captureFunctions.sqf triggerLogic1 = { hint "triggerLogic1 spawned"; sleep 3; _trigger = _this select 0; //The trigger in the editor _marker = _this select 1; //The Marker in the editor _timerWest = 0; //Starts the timer at 0 _timerEast = 0; _timerResistance = 0; _timerLimit = 30; //Amount of time needed to capture the area _currentOwner = "civ";//The default owner _westCount = 0; _eastCount = 0; _resistanceCount = 0; while {true} do { waitUntil{ sleep 1; _unitArray = list _trigger; //Get a list of all players in the trigger area then split them according to their side _westCount = west countSide _unitArray; _eastCount = east countSide _unitArray; _resistanceCount = resistance countSide _unitArray; hstring = "waiting"; publicVariable "hstring"; ( _westCount >=1 && !(_currentOwner == "west")) || (_eastCount >=1 && !(_currentOwner == "east")) || (_resistanceCount >=1 && !(_currentOwner == "resistance")) };//Pauses the loop until someone who can capture the area has entered i.e not someone who currently owns it if(_currentOwner != "west")then{ if(_westCount > _eastCount && _westCount > _resistanceCount)then{_timerWest = _timerWest + 1;}; //Check which side has the most players in the area and increase their capture progress }; if(_currentOwner != "east")then{ if(_eastCount > _westCount && _eastCount > _resistanceCount)then{_timerEast = _timerEast + 1;}; }; if(_currentOwner != "resistance")then{ if(_resistanceCount > _westCount && _resistanceCount > _eastCount)then{_timerResistance = _timerResistance + 1;}; }; if(_timerWest == _timerLimit)then{_marker setMarkerColor "ColorBlue";_timerWest = 0;_timerEast = 0;_timerResistance = 0;_currentOwner = "west";};//Once the capture progress reaches the limit, the area now becomes theirs. if(_timerEast == _timerLimit)then{_marker setMarkerColor "ColorRed";_timerWest = 0;_timerEast = 0;_timerResistance = 0;_currentOwner = "east";}; if(_timerResistance == _timerLimit)then{_marker setMarkerColor "ColorGreen";_timerWest = 0;_timerEast = 0;_timerResistance = 0;_currentOwner = "resistance";}; hstring = format ["West Count:%1\n East Count: %2\n Resistance Count: %3\n \nWest Timer: %4\n East Timer: %5\n Resistance Timer: %6\n \nCurrent Owner: %7",_westCount,_eastCount,_resistanceCount,_timerWest,_timerEast,_timerResistance,_currentOwner]; publicVariable "hstring"; }; }; Share this post Link to post Share on other sites
chaoticgood 11 Posted September 19, 2013 Thanks you very much Larrow, it works perfectly now! Share this post Link to post Share on other sites