Jump to content
avibird 1

Need some help for a code to give non playable units unlimited oxygen underwater to prevent death.AI units unlimited oxygen underwater

Recommended Posts

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.

  • Like 1

Share this post


Link to post
Share on other sites

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;
}; 
};

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×