Author Topic: Player Control Other Vehicles  (Read 1197 times)

Okay, so i was thinking of a handy event which somebody secretly had.
It was an avatar RPG, you can go something like:
onactivate>client>VehicleControl>[ListofVehiclesThatIsHisOnly]
And your body stays there and you control the vehicle.
Then something like:
onplayertalk>client>Talked>Out -Please make to
ontalked>client>Exit Vehicle Control
Which would mean when a player says out, he leaves the vehicle, and the vehicles stays where the player moved it.
Just a request Please make!
« Last Edit: April 03, 2010, 06:00:16 PM by Light And Day »

Common name.
I thought you knew better.

What? I can't decode what the hell you just said. -Quote from Badspot

1. Do not post ambiguous topics.  The title of your thread should describe it's contents.  If you are asking a question, there should be a question mark at the end.  Ambiguous topics will be locked. - Quote from Badspot

An awesome way to do setControlObject is like this:

Name the vehicle spawn v
do localClientConnection.setCont rolObject(_v.vehicle);
Bam, you control that vehicle.
To fix, hit f7 or type localClientConnection.setCont rolObject(localclientconnection.player);

This is a real event. I forget what it's called, but look on RTB. I have the thing.

It's the buggiest piece of stuff.

This is a real event. I forget what it's called, but look on RTB. I have the thing.

It's the buggiest piece of stuff.
Ba-Va-Ha-Wa? RTB2/3?
Thank you.

I'm pretty sure it can be done with VCE

it's already been made, and you can use VCE for the last msg, and there is an event of onplayertalk (which is when they enter a message while touching a brick)

Whats it called, its not helping saying "Its made" where would i find it? And whats it called?

package RcController
{
   function WheeledVehicleData::OnTrigger(%this, %obj, %triggerNum, %val)
   {
         if(%val)
      {
               if(%triggerNum == 4)
         {
            %Client = %obj.getControllingClient();
            switch(%Client.isRcing)
            {
               case 0:
                  Parent::OnTrigger(%this, %obj, %triggerNum, %val);
               case 1:
                  servercmdTurnOff(%Client);
            }
         }
      }
   }

   function FlyingVehicleData::OnTrigger(%this, %obj, %triggerNum, %val)
   {
         if(%val)
      {
               if(%triggerNum == 4)
         {
            %Client = %obj.getControllingClient();
            switch(%Client.isRcing)
            {
               case 0:
                  Parent::OnTrigger(%this, %obj, %triggerNum, %val);
               case 1:
                  servercmdTurnOff(%Client);
            }
         }
      }
   }
};
ActivatePackage(RcController);

function RCControllerImage::onFire(%This,%Player,%Slot)
{
   %Client = %Player.Client;
   InitContainerRadiusSearch (%Player.getPosition(),2,$TypeMasks::VehicleObjectType);
   while((%Vehicle = ContainerSearchNext()) != 0 )
   {
      %VehicleNum++;
      %ConVehicle = %Vehicle;
   }
   if(%ConVehicle $= %Player.getObjectMount())
   {
   }
   else if(%VehicleNum <= 0 || !isObject(%ConVehicle))
   {
      commandToClient(%Client,'centerprint',"You must be near a vehicle.",1);
   }
   else if(%VehicleNum > 1)
   {
      commandToClient(%Client,'centerprint',"To many vehicles around.",1);
   }
   else if(%ConVehicle.getControllingClient() || %ConVehicle.isRC)
   {
      commandToClient(%Client,'centerprint',"That vehicle is already being driven.",1);
   }
   else if(getTrustLevel(%ConVehicle.spawnbrick.client,%Client.player) < 2)
   {
      commandToClient(%Client,'CenterPrint',%ConVehicle.spawnBrick.getGroup().name SPC "does not trust you enough to RC this.",3);
   }
   else if(!%Client.isRcing)
   {
      %Client.RCVehicle = %ConVehicle;
      %Client.isRcing = 1;
      %ConVehicle.isRC = 1;
      CheckRcDistance(%Client,%Player,%ConVehicle);
      commandToClient(%Client,'centerprint',"The RC Controller is now on.",1);
   }
}

function CheckRcDistance(%Client,%Player,%Vehicle)
{
   if(isObject(%Player) && isObject(%Vehicle))
   {
      %Player.setControlObject(%Vehicle);
      %PPos = %Player.getPosition();
      %VPos = %Vehicle.getPosition();
      %Vec = VectorSub(%PPos,%VPos);
      %Len = VectorLen(%Vec);
      %Len = %Len / 0.5;
      %Len = %Len - 1;
      if(%Len < 2500 && %Len > 2200)
      {
         commandToClient(%Client,'centerprint',"WARNING!: ALMOST OUT OF RANGE!",0.6);
      }
      else if(%Len > 2500)
      {
         serverCmdTurnOff(%Client);
         return;
      }
      %Player.Client.RcEvent = schedule(500,0,"CheckRcDistance",%Client,%Player,%Vehicle);
   }
   else
   {
      servercmdTurnOff(%Client);
   }
}

function servercmdTurnOff(%Client)
{
   if(%Client.isRcing)
   {
      %Client.RCVehicle.setVelocity("0 0 0");
      %Client.RCVehicle.isRC = 0;
      %Client.player.setControlObject(%Client.Player);
      %Client.isRcing = 0;
      cancel(%Client.RcEvent);
      commandToClient(%Client,'centerprint',"The RC Controller is now off.",1);
   }
   else
   {
      commandToClient(%Client,'centerprint',"The RC Controller is already off.",1);
   }
}

RC controler script. Now lets see what we can do with it?
package VehicleControl
{
   function WheeledVehicleData::OnTrigger(%this, %obj, %triggerNum, %val)
   {
         if(%val)
      {
               if(%triggerNum == 4)
         {
            %Client = %obj.getControllingClient();
            switch(%Client.isControling)
            {
                  Parent::OnTrigger(%this, %obj, %triggerNum, %val);
            }
         }
      }
   }

   function FlyingVehicleData::OnTrigger(%this, %obj, %triggerNum, %val)
   {
         if(%val)
      {
               if(%triggerNum == 4)
         {
            %Client = %obj.getControllingClient();
            switch(%Client.isControllinging)
            {
                  Parent::OnTrigger(%this, %obj, %triggerNum, %val);
            }
         }
      }
   }
};
ActivatePackage(VehicleControl);
That can begin it. With you know... The thing that trigger... I have no clue. Maybe that enables it? What ever ^_^