avibird 1 155 Posted December 8, 2024 Hi I have this snippet of code that I use in my missions it allows human and AI playable units to have unlimited oxygen while under the water no death will occur due to lack of oxygen. Code is placed in initPlayerLocal.sqf AddMissionEventHandler ["eachframe", { if (getoxygenremaining player < 0.1) then { player setoxygenremaining 0.1 }}]; I attempted to use the code to get all AI units non-playable to get unlimited oxygen while underwater but this does not work. Code was placed In server.sqf AddMissionEventHandler ["eachframe", { if (getoxygenremaining foreach allunit< 0.1) then { foreach allunit setoxygenremaining 0.1 }}]; This does not work for non playable AI units. Any help would be greatly appreciated. 1 Share this post Link to post Share on other sites
soldierXXXX 121 Posted December 8, 2024 Hi, your code has wrong syntax. Trying to call the code every frame might decrease performance and cause network traffic to be filled with requests. That would certainly cause desynchronization and potentially even game crashes. Try to put this simple code into initServer.sqf [] spawn { scriptName "OxygenSetter"; while {TRUE} do { allUnits apply {_x setOxygenRemaining 1;}; sleep 5; }; }; 1 1 Share this post Link to post Share on other sites
avibird 1 155 Posted December 16, 2024 @soldierXXXX does not work for AI units still drowned underwater. Any other ideas? Share this post Link to post Share on other sites
pierremgi 4944 Posted December 16, 2024 @avibird 1 The soldierXXXX works. You missed something, somewhere. Pay a sharp attention for command syntax. For example allUnits exists, allUnit nope. Just a question apart: how your AIs can be drowned? What circumstances? and why not simply give them a rebreather as long as they are underwater? 1 Share this post Link to post Share on other sites
avibird 1 155 Posted December 16, 2024 Some of my spawn units go into the water to try to flank or maneuver the battlefield. I am using a part of the map that I use your MGI module and JUBUS. I am using Tanoa a part of the map that has a lot of water separating various land masses. Some units use VCOM AI. When using your AI spawn code I can add a code to stop VCOM AI to work on the units but after the initial group is killed in spawns back the extra code line added to the team leaders in it box does not carry over and the AI will go into the water to attempt to flank maneuver to engage and unfortunately some of them drown lol. I have a code line that prevents players and AI playable units to never drowned even if they're unconscious underwater but straight AI units will drown. I attempted to add it for all AI units with no luck. I will try to implement soldiers code again perhaps there's a typo. Share this post Link to post Share on other sites
soldierXXXX 121 Posted December 16, 2024 @avibird 1 May I ask, where did you put the code ? And have you modified it in any way ? Share this post Link to post Share on other sites
avibird 1 155 Posted December 16, 2024 Hey soldier I deleted the code and reinsert it into my initserver.sqf. the last test play AI units did not die when stuck on the water. Perhaps there was a typo. I will test play more. Share this post Link to post Share on other sites