Basically, look at a brick, type a server command, and have the coordinates of a brick presented to you.
Lilboarder's attempt (modified by me) worked perfectly, but only for basepates. Otherwise, the function did not seem able to find the object.
function servercmdobjtest(%client)
{
ClientCmdCenterPrint("You activated the function", 3);
%obj = %client.player;
%scale = vectorScale(%obj.getEyeVector(),100);
%ray = containerRaycast(%obj.getEyePoint(),%scale,$Typemasks::fxBrickObjectType);
%brick = firstWord(%ray);
messageClient(%client,'',%brick.getPosition());
ClientCmdCenterPrint("It probably didn't work", 3);
}
Iban's attempt was a lot more cleaned up and user friendly, although it didn't work at all. Everytime I called the function, I would always get "Look at a brick, dummy". After some testing, I determined that the function never actually found the object, for whatever reason.
function serverCmdObjTest(%client)
{
%obj = %client.player;
if(!isObject(%obj))
{
%client.centerPrint("\c5Spawn first, dummy.", 2);
return;
}
%fvec = %obj.getForwardVector();
%fX = getWord(%fvec, 0);
%fY = getWord(%fvec, 1);
%evec = %obj.getEyeVector();
%eX = getWord(%evec, 0);
%eY = getWord(%evec, 1);
%eZ = getWord(%evec, 2);
%eXY = mSqrt((%eX * %eX) + (%eY * %eY));
%aimVec = (%fX * %eXY) SPC (%fY * %eXY) SPC %eZ;
%range = 100;
%end = vectorAdd(%start, vectorScale(%aimVec, %range));
%masks = $TypeMasks::FxBrickAlwaysObjectType;
%col = firstWord(containerRayCast(%start, %end, %masks, %obj));
if(!isObject(%col))
{
%client.centerPrint("\c5Look at a brick, dummy.", 2);
return;
}
messageClient(%client, '', "\c5BRICK POSITION\c6:" SPC %col.getPosition());
echo("BRICK POSITION:" SPC %col.getPosition());
}
Any help would be appreciated greatly.