Jump to content

Recommended Posts

Hi guys!

First of all, sorry for my english, is not my mother tongue :f:

I was searching information about this, and just found one post from 2013. But don't work for me.

I just want to do my player not drown.

I use revive in my misión, and if a player is "killed" on a boat moving , the player falls to the water (don't know why this happens), to the botton of the river . I swim to the teammate  to revive him, but because of  the slow swimming, the oxygen time of his body is out and dies.

So, is there a way to make player not vulnerable to underwater? or a way to increase the time of the oxygen underwater?

I expect an answer, thanks in advance.

Share this post


Link to post
Share on other sites

You could do something like this:

_playerPos = getPosWorld player;
while {surfaceIsWater _playerPos} do {
	if ((getOxygenRemaining player) < 1) then {
    	player setOxygenRemaining 1;
	};

	// update position var and delay
    _playerPos = getPosWorld player;
	sleep 1;
};

For what you want you will have to modify it slightly, but it's a start :)

 

Hope that helps,

 

Bull

Share this post


Link to post
Share on other sites

Hey!

Thanks a lot for your quick response guys.

I forgot to say something.... I do not have much script knowledge,  :down:

So, could you explain me where do i have to put these lines? In the player's init? or have to do a script with it?

Share this post


Link to post
Share on other sites
On 2/20/2017 at 10:47 PM, Grumpy Old Man said:

Wonky solution.

You could check getposasl for a negative Z value and use setOxygenRemaining if true.

 

Cheers

 

Since the only place a person loses oxygen is under water, why would he need to check if player is under water not. Why not just keep it always at one??

Share this post


Link to post
Share on other sites
8 hours ago, BlacKnightBK said:

Since the only place a person loses oxygen is under water, why would he need to check if player is under water not. Why not just keep it always at one??

 

Maybe I misunderstood your question.

When the player object has a negative Z value from the getPosASL command (position above sea level), he's underwater.

Now additionally you can check if his oxygen value is under a certain level and set it to 1, but an additional check is really not necessary here.

 

The solution of bull_a will exit the while loop as soon as the players position is not above water, which defeats the purpose of a constantly running check.

 

There's multiple valid solutions, once a check only on the remaining oxygen:

While {alive player} do {
	
	if (getOxygenRemaining player < 0.3) then {player setOxygenRemaining 1};
	sleep 10;
};
                                        
//OR
                                        
While {alive player} do {
	
	if ((getPosASL player select 2) <= 0) then {player setOxygenRemaining 1};
	sleep 10;
};

Since a player drowns after a bit more than 60 seconds doing a check every 10 seconds should be fine.

Really no need to check for more than one condition in this case.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites
On ‎22‎/‎02‎/‎2017 at 3:17 PM, Grumpy Old Man said:

 

Maybe I misunderstood your question.

When the player object has a negative Z value from the getPosASL command (position above sea level), he's underwater.

Now additionally you can check if his oxygen value is under a certain level and set it to 1, but an additional check is really not necessary here.

 

The solution of bull_a will exit the while loop as soon as the players position is not above water, which defeats the purpose of a constantly running check.

 

There's multiple valid solutions, once a check only on the remaining oxygen:


While {alive player} do {
	
	if (getOxygenRemaining player < 0.3) then {player setOxygenRemaining 1};
	sleep 10;
};
                                        
//OR
                                        
While {alive player} do {
	
	if ((getPosASL player select 2) <= 0) then {player setOxygenRemaining 1};
	sleep 10;
};

Since a player drowns after a bit more than 60 seconds doing a check every 10 seconds should be fine.

Really no need to check for more than one condition in this case.

 

Cheers

Great!

This works perfectly

Thank you very much!!!

Share this post


Link to post
Share on other sites

Just take into account that this loop will stop upon a players death, so best reapply it with the onPlayerRespawn.sqf or wherever you seem fit.

 

Cheers

Share this post


Link to post
Share on other sites

Hey I don't know if you got this to work for you however I modified a  revive script that units playable units will never I only go unconscious even under water with a trigger to end the mission when all playable units are unconscious. I also added a script that allows you to drag and load units into vehicles. So when you have a pilot shot down over the water you need to do a search and rescue with divers to revive those units. This works for my needs. Let me know if you still need this. Avibird 

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

×