Jump to content
Sign in to follow this  
ffur2007slx2_5

What's wrong with setpos?

Recommended Posts

Now I'm suffered with a problem that the code below sometimes works good but sometimes the engine report error: type Any, expected Number.

I can't figure it out why? Does anyone know it?

            
           _WCRRandomPlayerStartRangeUtes = 500;
           _WCRCenter = "LOGIC" createVehicleLocal [3578,3780,0];
           _WCROffset0 = ((position _WCRCenter select 0) + (random _WCRRandomPlayerStartRangeUtes));
           _WCROffset1 = ((position _WCRCenter select 0) - (random _WCRRandomPlayerStartRangeUtes));
           _WCROffset2 = ((position _WCRCenter select 1) + (random _WCRRandomPlayerStartRangeUtes));
           _WCROffset3 = ((position _WCRCenter select 1) - (random _WCRRandomPlayerStartRangeUtes));
           sleep 1;
           player setpos [([_WCROffset0,_WCROffset1] select (round (random 2))),([_WCROffset2,_WCROffset3] select (round (random 2))),0];

My purpose is player can be generated randomly around a specific point.

Edited by ffur2007slx2_5

Share this post


Link to post
Share on other sites

Reason is that you use round. Only two items in array and round can return three. Random value of 2 can return a value in range 1.5 - 1.99. Rounding that will make it 2, which it 3rd position in an array. Should use floor with randoms instead.

However, why are you creating a logic instead of just randomizing the position straight away? You already know range and center position.

Share this post


Link to post
Share on other sites
However, why are you creating a logic instead of just randomizing the position straight away? You already know range and center position.

One good reason is a forest. Random placement doesn't work in the woods.

Share this post


Link to post
Share on other sites
One good reason is a forest. Random placement doesn't work in the woods.

Sure it works.

Besides, creating a logic to a position and then getposing the position from it is kind silly. You already had the position in the first place.

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  

×