Vehicle mounted?
by Ronald J Nelson · in Technical Issues · 09/14/2005 (7:35 am) · 4 replies
Does someone know how to first, find out if a vehicle is mounted already by another driver? Then second, if the vehicle has more than one mount point, allow them to enter one of those?
I have been trying a few things from the resources and they don't seem to work with TGE 1.3.
I have been trying a few things from the resources and they don't seem to work with TGE 1.3.
#2
09/14/2005 (2:52 pm)
This is what I am using to mount/dismount. Not using the find EmptySeat yet since some of my vehicles have only one mount node.function serverCmdMountVehicle(%client)
{
//Determine how far should the picking ray extend into the world?
%selectRange = 3;
// Only search for vehicles
%searchMasks = $TypeMasks::vehicleObjectType;
%pos = %client.player.getEyePoint();
// Start with the shape's eye vector...
%eye = %client.player.getEyeVector();
%eye = vectorNormalize(%eye);
%vec = vectorScale(%eye, %selectRange);
%end = vectorAdd(%vec, %pos);
%scanTarg = ContainerRayCast (%pos, %end, %searchMasks);
// a target in range was found so select it
if (%scanTarg)
{
%targetObject = firstWord(%scanTarg);
%col = %targetObject;
%obj = %client.getControlObject();
echo("Found a vehicle: " @ %targetObject);
// Mount vehicles
%this = %col.getDataBlock();
// Only mount drivers for now.
%node = 0;
//%node = findEmptySeat(%col, %this);
%col.mountObject(%obj,%node);
%obj.mVehicle = %col;
%obj.client.setcontrolobject(%col);
}
else
{
echo("No object found/Try dismount");
if (!%scanTarg)
{
commandToClient(%client,'getOut',%client);
%client.setControlObject(%client.player);
}
}
}
function findEmptySeat(%vehicle, %vehicleblock)
{
for (%i = 0; %i < %vehicleblock.numMountPoints; %i++)
{
%node = %vehicle.getMountNodeObject(%i);
if (%node == 0)
{
return %i;
}
}
return -1;
}
#3
%obj = %client.getControlObject(); this is the player
You can use %col.getMountNodeObject(nodenumber) or as it does in the findemptyseat,
then you get the mounted object on the specific vehicle node.
If no object is mounted then it return 0 , othervise it returning the objectId
You can test this in the console ,type echo(vehicleId.getmountnodeobject(nodenumber));
So to get this to work change to this
//%node = 0;
%node = findEmptySeat(%col, %this);
09/14/2005 (4:00 pm)
Quote:%col = %targetObject; this is the vehicle
Ok I guess what I am also not sure about now is which object is actually the mounted object. Is it the player, or the vehicle? If it is the player, how can you tell if the node in the car is already being used?
%obj = %client.getControlObject(); this is the player
You can use %col.getMountNodeObject(nodenumber) or as it does in the findemptyseat,
then you get the mounted object on the specific vehicle node.
If no object is mounted then it return 0 , othervise it returning the objectId
You can test this in the console ,type echo(vehicleId.getmountnodeobject(nodenumber));
So to get this to work change to this
//%node = 0;
%node = findEmptySeat(%col, %this);
#4
09/14/2005 (7:51 pm)
Wow that is perfect and exactly what I needed. Thank you for your help.
Torque Owner Ronald J Nelson
Code Hammer Games