Jump to content
Sign in to follow this  
5133p39

Keeping players safe during mission init and gamemode init?

Recommended Posts

I need to make sure nothing bad happens to players during the mission initialization process,

and during the gamemode initialization process after that.

By gamemode initialization i mean selecting various mission parameters, and unit type or gear selection, which takes some time and is done with the help of custom dialogs.

Some players are finished with the settings sooner and can start playing while other players are still choosing options in their dialog screens.

I want to protect the "slow" players from any possible harm done (enemy could shoot them, somebody could run them over with a vehicle, etc.).

At first i thought it would be safe to put the players somewhere far away into the water surrounding the island, but the players keeps dying from drowning.

The drowning happens because the player's view is switched to a camera showing some other location - if the camera is activated before some gameworld/player initialization is finished, the players won't start swimming, but instead they falls under the water.

Try for yourself:

Place some player unit (a soldier, not a boat ;)) somewhere into the deep sea, and create init.sqf countaining this code

CAM = "camera" camCreate (Player modelToWorld [3,3,1]);
CAM camSetTarget Player;
CAM cameraEffect ["INTERNAL", "BACK"];
CAM camCommit 0;
while {alive Player} do {
 player globalchat format["%1 health: %2", player, damage Player];
 sleep 1;
};

When you run this mission, you will see what the problem is.

* note: a zero damage is shown all the time, but the unit still drowns!

Is there some way to make sure the camera is activated AFTER the inner game initialization is done?

I tried finishMissionInit which doesn't seems to work (or maybe it does, but it doesn't help anyway).

I also tried various conditions, using many game variables and commands, to activate the camera after something is done, but i haven't found a solution.

The only thing that helps is placing sleep 1; before the camera activation - but this is something i consider to be a "dirty hack", because it helps when i am testing/playing, but in other environment it may not be enough.

You may suggest "ok, then make the delay 10 seconds to be sure", but under some unpredictable circumstances it still may not be enough, and ...well, i don't like it).

So, any other ideas than using N seconds delay?

Share this post


Link to post
Share on other sites
Make the unit inmortal.

Good idea, "Dammage" eventhandler works, and resetting the damage to zero also works (despite the fact that getDammage returns only zero).

If there will be no better way, then i will use this solution.

What i would want the most is to find out the cause and fix for this problem (like knowing which variable/command to check in a condition, before allowing activation of the camera), not only simple workarounds.

btw. a funny thing - if i set some time acceleration (like 4x), then the globalChat command in the sample init.sqf starts displaying correct results of the getDammage player (before the time acc. the result was allways zero).

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
Sign in to follow this  

×