Author Topic: getmountedobject crap  (Read 783 times)

I am making a feature where I need to get the player who is mounted to slot 1 'getmountedobject(1)'. if i am sitting in the bot vehicle and the player gets on, getmountedslot(1) will return me, even though I am in the drivers seat. wtf is wrong? i noticed this as a problem when making a driver only vehicle command too.
could it be related to this?
Code: [Select]
   function armor::onMount(%this,%obj,%col,%slot)
   {
      Parent::onMount(%this,%obj,%col,%slot);
      if(%col.getDataBlock().getId() == HeedTurret.getId())
      {
         %client = %obj.client;
         if(isObject(%client))
            ServerCmdUnUseTool(%client);
if(%slot $= 1)
{
if(%col.loaded != 0)
%obj.dismount();
else
%col.MountedPlayer = %obj;
}
      }
   }
the code i need it for:
Code: [Select]
   if(isobject(%mount.getmountedobject(1)))
   {
%player = %mount.getmountedobject(1);
%player.dismount();
%player.setTransform(%mount.getSlotTransform(2));
%player.setvelocity(getwords(%vec2,0,1) SPC %upforce);

   }
it should launch the player in slot 1, but if they mount after i am already mounted in slot 0, it will launch me.

have you tried doing getMountedObject(0)?

have you tried doing getMountedObject(0)?
wouldn't that just return the driver?? i need to find the person in seat 2 (aka slot 1)

wouldn't that just return the driver?? i need to find the person in seat 2 (aka slot 1)
you just said getMountedObject(1) returns the driver.

something is obviously not right here, let's rule that out.

also try getMountedObject(2);

no getmountedobject(1) returns the driver when it shouldn't. it sometimes returns the 2nd seat person, and sometimes returns the driver. it shouldn't be picking and choosing. it's supposed to return the second person.

heed stop being stubborn and try what i said.

i know what you said, now try what i said.

also where is %mount defined?

that did nothing like i thought.

the problem seems to be it doesnt detect when someone switches seats. i got into the turret and switched to seat 2 (1) and checked the getmountedobject(1) and it returned nothing, and then i checked getmountedobject(0) and it returned me, even though i was in seat 2.

perhaps it's the order the objects mount in?

yes, that must be it.

try something like getnummountedobjects()?

then for(%i = 0; %i < %obj.getNumMountedObjects(); %i++)
{
echo(getMountedObject(%i));
}

make sense? no? ok.

do %vehicle/%mount/whatever you're calling getMountedObject(#) on dump()
%obj.dump();

the same problem occurs in the rowboat as well. typing getmountedobject(0) will return the player even if he is not in slot 0. he could be in slot 1 2 3 or 4 but it seems to return whoever was last in the drivers seat. this entire function seems broken?

See Lugnut's answer. It's probably an array of mounted objects, rather than a map of one mount point to an object. You might have to loop through all mounted objects and figure out what slot each single object is actually mounted to.