Jump to content
Sign in to follow this  
florianmuellerch

speed of vehicle only works if player is the single person in the vehicle

Recommended Posts

I'm trying to get all vehicles speed of all players that are around my _pos. For every player I want to check if he's the driver of the vehicle, and if so I'm getting the speed and doing some other stuff.

Now, this works perfectly if the player drives a limousine alone. This won't work if the player drives an IFV with some other AI guys in it. The speed command gets called in both cases, but in the IFV case, speed returned 0.

EDIT: I just ensured that it works with the IFV if only the player is inside. So it must relate to the AI players and the vehiclerole

{
   _vehicle = assignedVehicle _x;
   if not (isNull _vehicle) then {
       if ((count(assignedVehicleRole _x) > 0) and (((assignedVehicleRole _x) select 0) =="Driver")) then {
           _speed = speed _vehicle;
           //with player as single civ limousine driver, this is the correct speed
           //with player as IFV driver, this returns 0
       };
   };
} forEach (_pos nearEntities 25);

What am I doing wrong here?

---------- Post added at 00:33 ---------- Previous post was at 23:32 ----------

Oh, my mistake...

NeadEntities does not return the driver, in this case only the Turred guy gets returned. But I check now for the role and if the role is not Driver, I'll use the assignedDriver of the turred guy's vehicle :)

Edited by florianmuellerCH

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  

×