Author Topic: Pressing Shift in a Vehicle  (Read 1184 times)

Is there a way to detect a person pressing shift while in a vehicle server-side? Seems like ::onTrigger is only called when space is pressed.

why are you asking?


[offtopic]welcome back?[/offtopic]

trace indicates that nothing is called if you crouch in the driver seat, but it does if you're a passenger.

Try mounting something to slot 3 and seeing if it fires when you crouch or crouch in a vehicle.

I've tried this, and the only way I could get it to echo anything, in or out of a vehicle, was to mount it to slot 0 and click :/
Code: [Select]
datablock shapeBaseImageData(gravityJeepCrouchImage){
 shapeFile="base/data/shapes/empty.dts";
 mountPoint=3;

 stateName[0] = "Ready";
 stateTransitionOnTriggerDown[0] = "Crouch";
 
 stateName[1] = "Crouch";
 stateTransitionOnTriggerUp[1] = "UnCrouch";
 stateScript[1] = "onCrouch";

 stateName[2] = "UnCrouch";
 stateTransitionOnTriggerDown[2] = "Crouch";
 stateScript[2] = "onUnCrouch";
};

function gravityJeepCrouchImage::onCrouch(%this,%obj,%slot){
 echo("CROUCH "@%this TAB %obj TAB %slot);
}

function gravityJeepCrouchImage::onUnCrouch(%this,%obj,%slot){
 echo("UNCROUCH "@%this TAB %obj TAB %slot);
}

Try
Code: [Select]
package gravityJeep
{
WheeledVehicle::onTrigger(%this,%obj,%slot,%state)
{
if(%slot == 3 && %state == 1 && %obj.getdatablock $= "gravityJeep")
{
echo("Do stuff");
//add a return if you want
}
Parent::onTrigger(%this,%obj,%slot,%state);
}
};
ActivatePackage(GravityJeep);

Slot 0 is mouseFire (default left click)
Slot 1 is altTrigger (not bindable by default)
Slot 2 is jump (default space)
Slot 3 is crouch (default left shift)
Slot 4 is jet (default right click) (do not use, used for exiting vehicles)

State 0 is off
State 1 is on

[edit]
Blah there is supposed to be tabs in there...
« Last Edit: October 28, 2008, 01:14:18 PM by Chrono »

For vehicles, onTrigger only seems to get called when the spacebar (slot 2) is pressed.

My bad...
Code: [Select]
package gravityJeep
{
armor::onTrigger(%this,%obj,%slot,%state)
{
if(%slot == 3 && %state == 1 && %obj.getObjectMount().getDataBlock().getName() $= "gravityJeep")
{
echo("Do stuff");
}
Parent::onTrigger(%this,%obj,%slot,%state);
}
};
activatePackage(gravityJeep);

Did you read what Zor said?

onTrigger is only called for the driver when they press Jump. There is no call to armor::onTrigger or vehicle::onTrigger when they crouch.

I tested this and it was called for other functions.