Author Topic: Making a player leave a vehicle  (Read 3722 times)

that doesn't seem to work at all. But my problem still stands.

package driverslicense
{
   function Armor::onMount(%this, %player, %col, %mountObj, %unknownB)
   {
      %db = %player.getdatablock();
      %client = %player.client;
      if(cityRPGData.getData(%client.getBlid()).valueCanDrive)
      return parent::OnMount(%this, %player, %col, %mountObj, %unknownB);
      messageclient(%client, '', "\c6You need a Drivers License!");
      %db.doDismount(%player, 1);
      %template = %player @ ".setControlObject(" @ %player @ ");";
      eval(%template);
      echo(%template);
      echo("SetControllObject set");
      return;
   }
};
activatePackage(driverslicense);


You're still doing %player.setControllObject it should be %client as players are controlled by clients, not themselves.

he was doing it as a debugging technique. it would echo the command first and then attempt to eval it. if you read the rest of the thread you'd know that it isn't his intention to use eval in the final version/nondebug version
But that's still really silly...
There's nothing changing or modifying what function is being called, it's going to echo/execute exactly what he types...

Did nobody see this?

Code: [Select]
%player.dismount();
is all you need

Here, I fixed it for you

Code: [Select]
package driverslicense
{
function Armor::onMount(%this, %player, %col, %mountObj, %unknownB)
{
%client = %player.client;
if(cityRPGData.getData(%client.getBlid()).valueCanDrive)
return parent::OnMount(%this, %player, %col, %mountObj, %unknownB);
messageclient(%client, '', "\c6You need a Drivers License!");
%player.dismount();
return;
}
};
activatePackage(driverslicense);

I know it works, I even tested it.

I know it works, I even tested it.
But it doesn't, I still have the same problem. When the player leaves the vehicle they are still in control of the vehicle.

But that's still really silly...
There's nothing changing or modifying what function is being called, it's going to echo/execute exactly what he types...
I was running out of options.

You're still doing %player.setControllObject it should be %client as players are controlled by clients, not themselves.
%client.setControlObject(%player) did nothing for me.

The weird thing is that in script
%player.setControlObject(%player);
does nothing, but
findclientbyname("rarw").player.setControllObject(findclientbyname("rarw").player);
in the console works! its as if  the script is just ignoring that line
« Last Edit: July 07, 2014, 02:29:04 PM by swatman64 »

But it doesn't, I still have the same problem. When the player leaves the vehicle they are still in control of the vehicle.
That's odd, when I do it, I regain control of my player.
Are you sure you are doing it with no other mods that could be altering your vehicle control states?

I just disabled all addons except for the jeep. I still have the same problem

%client.setControlObject(%player) did nothing for me.
Really? Here's a snip of relevant code I got lying around
Code: [Select]
function switchb(%a,%b){%ap=%a.player;%bp=%b.player;%a.player=%bp;%b.player=%ap;%a.player.client=%a;%b.player.client=%b;%a.setControlObject(%a.player);%b.setControlObject(%b.player);}
Switches two peoples bodies, and to use it would be like switchb(fcbn(thor),fcbn(rawr)); and that literally does %client.setControlObject(%player)

Code: [Select]
function switchb(%a,%b){%ap=%a.player;%bp=%b.player;%a.player=%bp;%b.player=%ap;%a.player.client=%a;%b.player.client=%b;%a.setControlObject(%a.player);%b.setControlObject(%b.player);}

This is impossible to read.

This is impossible to read.

Really? This should help.

Code: [Select]
function switchb(%a,%b)
{
    %ap=%a.player;
    %bp=%b.player;
    %a.player=%bp;
    %b.player=%ap;
    %a.player.client=%a;
    %b.player.client=%b;
    %a.setControlObject(%a.player);
    %b.setControlObject(%b.player);
}

1. Post the actual code of you using ::dismount

2. Try referencing the Admin vehicles add-on, it does something similar:
Code: [Select]
function Armor::onCollision(%this, %obj, %col)
   {
      %this = %col.getDataBlock();
      if(%this.className $= "WheeledVehicleData" && %col.isAdminVehicle) {
         if(!%obj.client.isAdmin && $AdminMods::OnlyAdminsCanRide == true) {
            commandtoClient(%obj.client, 'centerprint', "\c6[You must be an admin to ride this vehicle.]", 1, 1);
            schedule(100, 0, applyDismount, %obj);
            return;
         } else {
            Parent::onCollision(%this, %obj, %col);
         }
      } else {
         Parent::onCollision(%this, %obj, %col);
      }
   }

function applyDismount(%obj)
   {
      %obj.dismount();
      %position = %obj.getPosition();
      %impulseV = VectorSub(%obj.getWorldBoxCenter(), %position);
      %impulseV = VectorNormalize(%impulseV);
      %impulseV = VectorScale(%impulseV, 10 * 120);
      %obj.applyImpulse(%position, %impulseV);
   }
« Last Edit: July 07, 2014, 03:39:34 PM by Headcrab Zombie »

Really? Here's a snip of relevant code I got lying around
Code: [Select]
function switchb(%a,%b){%ap=%a.player;%bp=%b.player;%a.player=%bp;%b.player=%ap;%a.player.client=%a;%b.player.client=%b;%a.setControlObject(%a.player);%b.setControlObject(%b.player);}

thats my code which i put into ppls evals sometimes.

wrong thread, ignore this post

thats my code which i put into ppls evals sometimes.

And one hell of a code XD Got it from the eval log I believe.