OnVehicleClicked

Author Topic: OnVehicleClicked  (Read 941 times)

Title says it all. When a vehicle is clicked it triggers the event.


No, like, example:

OnVehicleClicked->Player->AddHealth->100

I'm sure there is an onVehicleActivate somewhere.

Edit: I see you already asked for this.
http://forum.blockland.us/index.php?topic=238358.0

I'm sure there is an onVehicleActivate somewhere.

Edit: I see you already asked for this.
http://forum.blockland.us/index.php?topic=238358.0
Wow, never noticed that.  XD


RegisterInputEvent(fxDtsBrick, "onVehicleClicked", "Self fxDtsBrick\tPlayer Player\tClient GameConnection\tMinigame Minigame");
package clickVehicle
{
   function Player::ActivateStuff(%obj)
   {
      Parent::ActivateStuff(%obj);
      %ray = containerRaycast(%obj.getEyePoint(),vectorAdd(%obj.getEyePoint(),vectorScale(%obj.getEyeVector(),10)),%mask,%obj);
      if(isObject(%col=firstWord(%ray))
         if(%col.getClassName()$="Vehicle")
            %col.onClick(%obj);
   }
};
activatepackage(clickVehicle);
function Vehicle::onClick(%obj,%player)
{
   if(!isObject(%obj.spawnBrick))
      return;
   $InputTarget_["Self"] = %obj.spawnBrick;
   $InputTarget_["Player"] = %player;
   $InputTarget_["Client"] = %player.client;
   $InputTarget_["Minigame"] = %player.client.minigame;
   %obj.spawnbrick.processInputEvent("onVehicleClicked", %player.client);
}


untested

Oh, wow. Thanks!
(I will package it, but am leaving topic unlocked for further discussion.)

I can just package that to an event?

I can just package that to an event?
yes, put it in a server.cs
and add a description.txt

TIL i could have made this better:
Vehicle::OnActivate(%vehicle, %activatingObj, %activatingClient, %pos, %vec)

TIL i could have made this better:
Vehicle::OnActivate(%vehicle, %activatingObj, %activatingClient, %pos, %vec)
Is that the entire script as compared to the last one, or do we have to paste that in somewhere?

Is that the entire script as compared to the last one, or do we have to paste that in somewhere?

RegisterInputEvent(fxDtsBrick, "onVehicleClicked", "Self fxDtsBrick\tPlayer Player\tClient GameConnection\tMinigame Minigame");
package clickVehicle
{
   function Vehicle::OnActivate(%obj, %activatingObj, %activatingClient, %pos, %vec)
   {
      Parent::OnActivate(%obj, %activatingObj, %activatingClient, %pos, %vec);
      if(!isObject(%obj.spawnBrick))
          return;
      $InputTarget_["Self"] = %obj.spawnBrick;
      $InputTarget_["Player"] = %activatingObj;
      $InputTarget_["Client"] = %activatingClient;
      $InputTarget_["Minigame"] = getMinigameFromObject(%activatingObj);
      %obj.spawnbrick.processInputEvent("onVehicleClicked", %activatingClient);
   }
};
activatepackage(clickVehicle);
« Last Edit: October 29, 2013, 09:01:18 PM by MARBLE MAN »

Is that the entire script as compared to the last one, or do we have to paste that in somewhere?
no, just package this

Code: [Select]
RegisterInputEvent(fxDtsBrick, "onVehicleClicked", "Self fxDtsBrick\tPlayer Player\tClient GameConnection\tMinigame Minigame");

package onVehicleClicked
{
function Vehicle::OnActivate(%obj, %activatingObj, %activatingClient, %pos, %vec)
{
Parent::OnActivate(%obj, %activatingObj, %activatingClient, %pos, %vec);
if(isObject(%obj.spawnBrick))
{
$InputTarget_["Self"] = %obj.spawnBrick;
$InputTarget_["Player"] = %activatingObj;
$InputTarget_["Client"] = %activatingClient;
$InputTarget_["Minigame"] = %activatingClient.minigame;
%obj.spawnbrick.processInputEvent("onVehicleClicked", %activatingClient);
}
}
};
activatePackage(onVehicleClicked);
« Last Edit: October 28, 2013, 09:39:36 PM by Subpixel »

Made a few changes to the script and am done packaging, works like a charm!

Made a few changes to the script and am done packaging, works like a charm!
What would you need to change...?