Author Topic: onPlayerDamaged  (Read 732 times)

I need the function for when a player takes damage. Specifically IF the player is mounted to %newcar. Here's the code I want to add it to:
Code: [Select]
function Player::startSkiJumping(%obj)
{
//make a new ski vehicle and mount the player on it
%client = %obj.client;
%position = %obj.getTransform();
%posX = getword(%position, 0);
%posY = getword(%position, 1);
%posZ = getword(%position, 2);
%rot = getWords(%position, 3, 8);

%posZ += 0.3;

%vel = %obj.getVelocity();

%newcar = new WheeledVehicle()
{
dataBlock = skijumpvehicle;
client = %client;
initialPosition = %posX @ " " @ %posY @ " " @ %posZ;
};
%newcar.addVelocity(%vel);
%newcar.setTransform(%posX @ " " @ %posY @ " " @ %posZ @ " " @ %rot);
%newcar.addVelocity("0 0 0");
// %newcar.addVelocity(%obj.getRelativeVector("0 25 0"));
%newcar.schedule(250, mountObject, %obj, 0);
}
I'd like to make it so when a player is damaged, IF they are mounted to this vehicle, they tumble 0500.

Here's what I've come up with so far. It doesn't work at all though.
Code: [Select]
package ParkourDamaged
{
        function player::onDamage(%obj)
        {
                if(%target.parkouractive = 1)
        {
                %obj.dismount();
                tumble(%obj,0500);
                %obj.parkouractive = 0;
            }
    }
};activatePackage(ParkourDamaged);

function Player::startSkiJumping(%obj)
{
//make a new ski vehicle and mount the player on it
%client = %obj.client;
%position = %obj.getTransform();
%posX = getword(%position, 0);
%posY = getword(%position, 1);
%posZ = getword(%position, 2);
%rot = getWords(%position, 3, 8);
%client.parkouractive = 1;

%posZ += 0.3;

%vel = %obj.getVelocity();

%newcar = new WheeledVehicle()
{
dataBlock = skijumpvehicle;
client = %client;
initialPosition = %posX @ " " @ %posY @ " " @ %posZ;
};
%newcar.addVelocity(%vel);
%newcar.setTransform(%posX @ " " @ %posY @ " " @ %posZ @ " " @ %rot);
%newcar.addVelocity("0 0 0");
%newcar.schedule(250, mountObject, %obj, 0);
}

Stop using @ " " @ , you can just use SPC for that.

Also, you're using the conditional "set %target.parkourActive to one", which will always be true. Not to mention the lack of a defined %target in the first place (which actually causes it to be false.)


Yeah you forgot to define %target
you need to fix that

Latest Code:
Code: [Select]
package ParkourDamaged
{
        function Armor::onDamage(%data,%this,%damage)
    {
        parent::onDamage(%data,%this,%damage);
        if(%this.parkouractive)
        {
            %this.dismount();
        }
    }
};
activatePackage(ParkourDamaged);

function Player::startSkiJumping(%obj)
{
//make a new ski vehicle and mount the player on it
%client = %obj.client;
%position = %obj.getTransform();
%posX = getword(%position, 0);
%posY = getword(%position, 1);
%posZ = getword(%position, 2);
%rot = getWords(%position, 3, 8);
        %obj.parkouractive = 1;

%posZ += 0.3;

%vel = %obj.getVelocity();

%newcar = new WheeledVehicle()
{
dataBlock = skijumpvehicle;
client = %client;
initialPosition = %posX @ " " @ %posY @ " " @ %posZ;
};
%newcar.setTransform(%posX @ " " @ %posY @ " " @ %posZ @ " " @ %rot);
%newcar.addVelocity("0 0 0");
%newcar.schedule(250, mountObject, %obj, 0);
%newcar.addVelocity(%vel);
}

function Player::stopSkiJumping(%obj)
{
        %vel = %obj.getobjectmount().getvelocity();
        %vel = getwords(%vel,0,1);
        %vel = %vel @ " 1";
        %obj.setvelocity(%vel);
%obj.dismount();
%obj.playThread(3,plant);
%obj.parkouractive = 0;
%obj.addVelocity("0 0 -10");
}

Use SPC instead of @. Example:
Code: [Select]
(%client.name SPC "looked at" SPC %target.name)
« Last Edit: October 13, 2012, 02:55:32 AM by Advanced Bot »

I don't even understand what the problem is now. Does that code work or does it not?

I don't even understand what the problem is now. Does that code work or does it not?

The problem he's having now is that he deleted "%this.parkourActive = 0;" for some reason I cannot begin to fathom.