Author Topic: Vehicle Scale similar to "PlayerScaleFull": Need a coding check  (Read 10070 times)

I can't tell if this will work out from my current computer. I can't test it from this because it's a stinkin chromebook. This is heavily borrowed code and I'm just wondering if this will even work at all;
Original code (from PlayerSetScaleFull)
Quote
function Player::setPlayerScaleFull(%this, %x, %y, %z)
{
   if(!isObject(%this) || %x < 0.1 || %y < 0.1 || %z < 0.1)
      return;
   %this.setPlayerScale(%x, %y, %z);
}

registerOutputEvent(Player, "setPlayerScaleFull", "int 0.1 5 1   int 0.1 5 1   int 0.1 5 1");

Code for "SetVehicleScaleFull"
Quote
registerOutputEvent(Vehicle, "setVehicleScaleFull", "int 0.1 5 1    int 0.1 5 1 int 0.1 5 1");

function Vehicle::setVehicleScaleFull(%vehicle, %x, %y, %z)
   {
      %scale = %scale SPC %scale SPC %scale;
      %vehicle.setScale(%scale);
      if(isObject(%vehicle.turret))
      {
         %vehicle.turret.setScale(%scale);
      }
   }

%scale never gets defined, except for setting it equal to "  " and I don't think you can scale a vehicle by three blanks.

Your editor replaces tabs by 4 spaces, that's nice for indention but I'm pretty sure you can't register the event with that. Replace it with this:

registerOutputEvent(Vehicle, "setVehicleScaleFull", "int 0.1 5 1\tint 0.1 5 1\tint 0.1 5 1");

%scale never gets defined, except for setting it equal to "  " and I don't think you can scale a vehicle by three blanks.
And this

So you can't scale a physics vehicle by x y z dimensions like you can with a player object?

Of course you can? I don't think you really read those replies, that's not at all what they're trying to say.

I'm not a coder, so sorry if I'm slow to understand these things
I did realize after reading it 4 times what he was saying, so I'll try and see if I can get this going. Thanks for the help so far guys

I've got the server.cs to activate. And the event does set a scale!
...Unfortunately it's a set one, no matter what variable you put in.
Quote
registerOutputEvent(Vehicle, "setVehicleScaleFull", "int 0.1 5 1\tint 0.1 5 1\tint 0.1 5 1");

   function Vehicle::setVehicleScaleFull(%vehicle, %scale, %x, %y, %z)
   {
      %scale = %x SPC %y SPC %z;
      %vehicle.setScale(%scale);
      if(isObject(%vehicle.turret))
      {
         %vehicle.turret.setScale(%scale);
      }
   }
Result:

I also tried this:
Quote
registerOutputEvent(Vehicle, "setVehicleScaleFull", "int 0.1 5 1\tint 0.1 5 1\tint 0.1 5 1");

   function Vehicle::setVehicleScaleFull(%vehicle, %scale, %x, %y, %z)
   {
      %scale = %x SPC %y SPC %z;
      %vehicle.setScale(%scale);
      if(isObject(%vehicle.turret))
      {
         %vehicle.turret.setScale(%scale);
      }
   }
But that caused really weird glitching with the models when I added %scale to requirements

Take out %scale from the arguments in the function definition.
Right now, your three arguments from the event, instead of passing to x, y, and z, are passing to scale, x, and y, so the final scale your using in set scale is "y z  " instead of "x y z"

It's also worth noting that int stands for integer. Which means a whole number. Which means that the whole 0.1 thing won't fly.


ITS ALIVE

Thanks everyone for the help! You guys are all awesome!! :)

It's also worth noting that int stands for integer. Which means a whole number. Which means that the whole 0.1 thing won't fly.
I tried changing to floating point but it always rounded off to 1.100 on x, y, and z

Here's the final code in case anyone who's reading this later might want it!
Quote
registerOutputEvent(Vehicle, "setVehicleScaleFull", "int 0.1 5 1\tint 0.1 5 1\tint 0.1 5 1");

   function Vehicle::setVehicleScaleFull(%vehicle, %x, %y, %z)
   {
      %vehicle.setScale(%x SPC %y SPC %z);
      if(isObject(%vehicle.turret))
      {
         %vehicle.turret.setScale(%x SPC %y SPC %z);
      }
   }

You should be using float instead of int. The fact that it
always rounded off to 1.100 on x, y, and z
means you were using it wrong, not that it didn't work.

Take a look at the stickied Event System - Register Inputs/Outputs topic, float takes 4 arguments, MINIMUM MAXIMUM STEPSIZE DEFAULT. I'm gonna take a guess and say you supplied it with the same arguments you were supplying int, so you were setting the min to 0.1, the max to 5, the stepsize to 1, and default to an empty string, which would be used as 0. So when you tried to adjust it, it would round the setting off to the nearest 1, add min, which is why it was on 1.1. To use it correctly, you should give it a stepsize of 0.1 (or somewhere around there).

A better option actually might be "vector".