Author Topic: Who's on my Vehicle?  (Read 1264 times)

I'm currently across a small piece of trouble with my Area Zones script. I can't figure out how to find out who is currently on a vehicle (besides the driver, that one is simple enough). I need help getting a script together that can determine if any passengers are on any vehicles and their individual object numbers. Any ideas?

getMountedObjectCount helps get a number of people on the vehicle (including a driver), so I have that much. Getting that information with getMountedObject should be simple enough, but the trick is finding out where each object is mounted. Should I just do a sweep of getmountedobjects? If I could find out how many mount points a vehicle has, this would actually work out quite well.

Code: [Select]
%vehicle.getDatablock().numMountPoints
That'll get the number of mount points.

Code: [Select]
for(%i=0; %i<%vehicle.getDatablock().numMountPoints; %i++){
   %player = %vehicle.getMountedObject(%i);
      if(%player != 0){
         //whatever you want to do to the person
      }
}

That'll get you anyone who's mounted to the vehicle.

Code: [Select]
for(%i=0; %i<%vehicle.getDatablock().numMountPoints; %i++){
   %player = %vehicle.getMountedObject(%i);
      if(%player != 0){
         //whatever you want to do to the person
      }
}

That'll get you anyone who's mounted to the vehicle.

He knows how to do that, he's just wondering whether there is another way.

Code: [Select]
for(%i=0; %i<%vehicle.getDatablock().numMountPoints; %i++){
   %player = %vehicle.getMountedObject(%i);
      if(%player != 0){
         //whatever you want to do to the person
      }
}

That'll get you anyone who's mounted to the vehicle.

He knows how to do that, he's just wondering whether there is another way.

I saved him the work.

I'd change it to the following:

Code: [Select]
for(%i=0; %i<%vehicle.getDatablock().numMountPoints; %i++)
{
     %player = %vehicle.getMountedObject(%i);

     if(isObject(%player))
     {
          //whatever you want to do to the person
     }
}

Code: [Select]
%vehicle.getDatablock().numMountPoints
That'll get the number of mount points.
Thanks, everyone, but this was all I needed. :D

Note: Posting from a Wii. It's annoying to type.