Author Topic: Questions  (Read 4739 times)

Code: [Select]
package overwritecrap2
{

function HorseArmor::onAdd(%this,%obj)
{
   // Vehicle timeout
   %obj.mountVehicle = true;

   // Default dynamic armor stats
   %obj.setRepairRate(0);

}

//called when the driver of a player-vehicle is unmounted
function HorseArmor::onDriverLeave(%obj, %player)
{
%obj.Mounted = 0;
}
function armor::onMount(%this,%obj,%col,%slot)
{
      Parent::onMount(%this,%obj,%col,%slot);
      if(%col.getDataBlock() == HorseArmor.getId())
{
%col.Mounted = 1;
}
}





function armor::onCollision(%this, %obj, %col, %fade, %pos, %normal)
{
parent::onCollision(%this, %obj, %col, %fade, %pos, %normal);
if(%obj.dataBlock.getName() $= "HorseArmor" && %obj.getState() !$= "Dead")
{
if(%this.Mounted = 1)
{

if(%col.getType() & $Typemasks::PlayerObjectType)
{
if(%col.getState() $= "Dead")
{
return;
}
else
{
tumble(%col, 7000);
}
}
}
}
}
};
activatePackage(overwritecrap2);
It isn't checking if the player is mounted. I want it so if the horse has no driver, it won't tumble people. Once the horse has a driver, it can tumble people it rams in to.

You're not checking if %this.Mounted is equal to 1; what you're checking is if the result of assinging 1 to %this.Mounted is not "" nor 0. You need to use == for numerical comparisons, not =.

Code: [Select]
function HorseArmor::onDriverLeave(%obj, %player)
{
%obj.Mounted = 0;
}
function armor::onMount(%this,%obj,%col,%slot)
{
      Parent::onMount(%this,%obj,%col,%slot);
      if(%col.getDataBlock() == HorseArmor.getId())
{
%col.Mounted = 1;
}
}





function armor::onCollision(%this, %obj, %col, %fade, %pos, %normal)
{
parent::onCollision(%this, %obj, %col, %fade, %pos, %normal);
if(%obj.dataBlock.getName() $= "HorseArmor" && %obj.getState() !$= "Dead")
{
if(%this.Mounted == 1)
{

if(%col.getType() & $Typemasks::PlayerObjectType)
{
if(%col.getState() $= "Dead")
{
return;
}
else
{
tumble(%col, 7000);
}
}
}
}
else
echo("NOO");
}
};
activatePackage(overwritecrap2);
It echoes NOO in the console when I try ramming.

Now it says it cannot find the tumble function

Was the function for tumble seriously removed? If so, that is stupid.

Was the function for tumble seriously removed? If so, that is stupid.

No, because the skis use it and I did myself in a throw script just a couple months ago (still V13).

No, because the skis use it and I did myself in a throw script just a couple months ago (still V13).
Then why does it say it cannot find the tumble function when I try ramming.


Bump for question
Was the function for tumble seriously removed? If so, that is stupid.
No, because the skis use it and I did myself in a throw script just a couple months ago (still V13).
Then why does it say it cannot find the tumble function when I try ramming.

New question for now. I am making vehicles cost money, but how would I check to see how much money the player has?

Code: [Select]
function fxDTSBrick::setVehicle(%brick, %vehicle)
{
if(!isObject(%brick.getGroup().client) || !%brick.getGroup().client.isAdmin)
{
if(isObject(%vehicle))
{
for(%a = 0; $RP::vehicles::banned[%a] !$= "" && !%hasBeenBanned; %a++)
{
if(%vehicle.getName() $= $RP::vehicles::banned[%a])
{
if(isObject(%brick.getGroup().client))
{
messageClient(%brick.getGroup().client, '', "\c6Standard users may not spawn a\c3" SPC %vehicle.uiName @ "\c6.");
}
%vehicle = 0;
%hasBeenBanned = true;
}
}
}
}


parent::setVehicle(%brick, %vehicle);
}

%brick.getGroup().client.Variable
Replace variable with the variable you saved the money to.

Code: [Select]
function fxDTSBrick::setVehicle(%brick, %vehicle)
{
if(%brick.getDatablock().getName() !$= "RPPublicVehicleData")
{
if(!isObject(%brick.getGroup().client))
{
if(isObject(%vehicle))
{
for(%a = 0; $RP::vehicles::allowed[%a] !$= "" && !%hasBeenyes; %a++)
{
if(%vehicle.getName() $= $RP::vehicles::allowed[%a])
{
if(isObject(%brick.getGroup().client))
{
if(%brick.getGroup().client.Roleplay["Gold"] >= 100)
{
messageClient(%brick.getGroup().client, '', "\c6You spawned a\c3" SPC %vehicle.uiName @ "\c6.");
%brick.getGroup().client.Roleplay["Gold"] -= 100;

}
else
{
messageClient(%brick.getGroup().client, '', "\c6You need more gold to spawn a\c3" SPC %vehicle.uiName @ "\c6.");
}
}
%vehicle = 0;
%hasBeenyes = true;
}
else
if(isObject(%brick.getGroup().client))
{
messageClient(%brick.getGroup().client, '', "\c6You are not allowed to spawn a\c3" SPC %vehicle.uiName @ "\c6.");
}
}
}
}
}

parent::setVehicle(%brick, %vehicle);
}
This is packaged, but doesn't work in game. Nothing happens, i just normally spawn a vehicle.

What about checking when a vehicle is damaged or when all projectiles damage. I know there is this:
Code: [Select]
function somethingprojectile::damage(%this,%obj,%col,%fade,%pos,%normal)
but is there something like
Code: [Select]
function damage(%this,%obj,%col,%fade,%pos,%normal)
that is called when any projectile damages any thing?

What about checking when a vehicle is damaged or when all projectiles damage. I know there is this:
Code: [Select]
function somethingprojectile::damage(%this,%obj,%col,%fade,%pos,%normal)
but is there something like
Code: [Select]
function damage(%this,%obj,%col,%fade,%pos,%normal)
that is called when any projectile damages any thing?

ProjectileData::Damage

Code: [Select]
function ProjectileData::damage(%this,%obj,%col,%fade,%pos,%normal)
{
   if(%col.dataBlock.getName() $= "TankVehicle") //Only works on certain vehicles
{
if(%this.VehiDamage > 0) //I set a thing in certain weapon's script that say this
//VehiDamage        = 30;
//THis part of the script should check if the weapon has VehiDamage set.
{
    %Vehidamage2 = %this.VehiDamage; //Sets a variable for the projectile's Vehidamage
{
//How would I damage the vehicle according to %vehidamage2?
}
}
}
}
//Also, where would I put the Parent::onsomething and what would the parent be called?
Most of it is explained by the comments.