Author Topic: Vehicles and ironsights  (Read 1789 times)

Code: [Select]
function Armor::onTrigger(%this, %player, %slot, %val)
{
if(%player.getMountedImage(0) $= Mac10Image.getID() && %slot $= 4 && %val)
{
if(!%obj.isMounted())
%player.mountImage(IronSightMac10Image,0);
}     
else if(%player.getMountedImage(0) $= IronSightMac10Image.getID() && %slot $= 4 && %val)
{
%player.mountImage(Mac10Image,0);
}
Parent::onTrigger(%this, %player, %slot, %val);
}
I am trying to make it so when you get out of a vehicle, you will not go to the iron sights, since both the gun and vehicle use the jet button. And yes, i packaged it, but it isn't included here.

What are you wondering?

What are you wondering?
I'm wondering what I am doing wrong, since it doesn't work.

if(!isObject(%obj.getObjectMount()))


you're not doing it right.

your code use %player instead of %obj. change the variable name

we've fixed it

Code: [Select]
function Armor::onTrigger(%this, %player, %slot, %val)
{
    if(%obj.getType() & $TypeMasks::PlayerObjectType)
    {
        if(%player.getMountedImage(0) $= Mac10Image.getID() && %slot $= 4 && %val && !%player.getObjectMount())
            %player.mountImage(IronSightMac10Image, 0);
        else if(%player.getMountedImage(0) $= IronSightMac10Image.getID() && %slot $= 4 && %val && !%player.getObjectMount())
            %player.mountImage(Mac10Image, 0);
        else
            parent::onTrigger(%this, %player, %slot, %val);
        return;
    }
    parent::onTrigger(%this, %player, %slot, %val);
}

I can tell you right now that code does not work at all.

%obj.getType() & $TypeMasks::PlayerObjectType

%obj is not defined. Checking if %player is a Player Type is also totally redundant and does nothing.

I can tell you right now that code does not work at all.

%obj.getType() & $TypeMasks::PlayerObjectType

%obj is not defined. Checking if %player is a Player Type is also totally redundant and does nothing.
Oh, yeah, sorry, that's an older version. I went back too far in the pad.

It does work, though.

and where did we check if it was a playertype or not i dont get it