rekkless 240 Posted March 24, 2018 I would like to set a gate to open at 6am and close at 6pm automatically without me having to manually do it. I'm sure there is a way via a trigger. I also plan on making the gate manually unopenable by using this setVariable ['bis_disabled_Door_1',1,true] the gate is a "TALL CONCRETE WALL (GATE)" object and in the mission I have to keep opening and closing it manually via Zeus due to the time. I would love to have it open and close on its own and not be able to be manipulated by other players. 1 Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted March 24, 2018 That's a simple one: //initServer.sqf or wherever you seem fit GOM_fnc_gateDaytimeAutomation = { params ["_building","_openTime","_closeTime","_isLocked"]; if (_isLocked) then {_building setVariable ['bis_disabled_door_1',1,true]}; _building animate ["Door_1_Move", 0];//close it initially while {alive _building} do { waitUntil {dayTime > _openTime AND dayTime < _closeTime}; _building animate ["Door_1_Move", 1]; waitUntil {dayTime > _closeTime}; _building animate ["Door_1_Move", 0]; } }; //put this when you want to automate the gate, initServer.sqf or wherever you seem fit _automateGate = [YourGate,8,19,true] spawn GOM_fnc_gateDaytimeAutomation; Will open the gate at 8 am, and close it at 7 pm, parameters are: Gate object name Opening time in format dayTime Closing time in format dayTime Prevent player interaction Using this as a function allows you to have multiple gates with multiple opening times. Cheers 2 Share this post Link to post Share on other sites
gizz46 28 Posted March 24, 2018 @rekkles You can defenetly do it as Grumpy Old Man explanded. But consider that this loop is running during the whole mission checking for the conditions to fullfill. Depending of your missiondesign you could also think about using a trigger, which only activates if yous as player is near the gate and then ckeck if the desired time had been reached. 1 Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted March 24, 2018 36 minutes ago, gizz46 said: @rekkles You can defenetly do it as Grumpy Old Man explanded. But consider that this loop is running during the whole mission checking for the conditions to fullfill. Depending of your missiondesign you could also think about using a trigger, which only activates if yous as player is near the gate and then ckeck if the desired time had been reached. It's not much of an issue to run something like this, even with no sleep in the waitUntil condition, since a simple daytime check takes about 0.0004ms on my rig (that's 400 nanoseconds, go figure), you'd have to do this check ~40.000 times to reach the runtime duration of a single frame at 60fps (16.6667ms). Let's say a frame at 60fps represents the lifespan of an average human, assuming 90 years for the 16.6667ms runtime. A single dayTime check would take barely more than two months of a 90 year lifespan, to put things into perspective, heh. Doing a 0.0004ms check once every 16.6667ms doesn't hurt, at all. Cheers Share this post Link to post Share on other sites
rekkless 240 Posted March 24, 2018 7 hours ago, Grumpy Old Man said: That's a simple one: //initServer.sqf or wherever you seem fit GOM_fnc_gateDaytimeAutomation = { params ["_building","_openTime","_closeTime","_isLocked"]; if (_isLocked) then {_building setVariable ['bis_disabled_door_1',1,true]}; _building animate ["Door_1_Move", 0];//close it initially while {alive _building} do { waitUntil {dayTime > _openTime AND dayTime < _closeTime}; _building animate ["Door_1_Move", 1]; waitUntil {dayTime > _closeTime}; _building animate ["Door_1_Move", 0]; } }; //put this when you want to automate the gate, initServer.sqf or wherever you seem fit _automateGate = [YourGate,8,19,true] spawn GOM_fnc_gateDaytimeAutomation; Will open the gate at 8 am, and close it at 7 pm, parameters are: Gate object name Opening time in format dayTime Closing time in format dayTime Prevent player interaction Using this as a function allows you to have multiple gates with multiple opening times. Cheers Thanks for the quick reply Just to be clear however. I can copy and paste that script into the mission and all I need to do is adjust the YourGate to say "G2" and name my gate G2 and it will open at 8am and close at 7pm? now that you have mentioned that the script can run on multiple gates, do you know if this will work on doors to building? Basically I've made a mission with a CBD (Central Business District) and it would be good if some of the businesses had their doors automatically open and close. Until you mentioned the script would work on multiple gates or doors I had only thought of the car yard that had the big fence gate. But if this will work on buildings too that would be awesome. Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted March 24, 2018 24 minutes ago, rekkless said: Thanks for the quick reply Just to be clear however. I can copy and paste that script into the mission and all I need to do is adjust the YourGate to say "G2" and name my gate G2 and it will open at 8am and close at 7pm? now that you have mentioned that the script can run on multiple gates, do you know if this will work on doors to building? Basically I've made a mission with a CBD (Central Business District) and it would be good if some of the businesses had their doors automatically open and close. Until you mentioned the script would work on multiple gates or doors I had only thought of the car yard that had the big fence gate. But if this will work on buildings too that would be awesome. Just name the gate object and adjust the times accordingly. dayTime is pretty simple, 16:30 will be 16.5, 08:45 will be 8.75. For 6 am and 7 pm simply use 6 and 19, that'll do. Take a look at the snippet I posted in this thread, might be what you're after. Cheers Share this post Link to post Share on other sites