Here you go:
function getDirectRightPoint(%player,%mag)
{
%curAim = %player.getEyeVector();
%curX = getWord(%curAim,0);
%curY = getWord(%curAim,1);
%curZ = getWord(%curAim,2);
%theta = mRadToDeg(mATan(%curY,%curX));
if(%curX > 0 && %curY > 0)
%angle = %theta;
else if(%curX < 0 && %curY > 0)
%angle = 180 - %theta;
else if(%curX < 0 && %curY < 0)
%angle = %theta + 180;
else if(%curX > 0 && %curY < 0)
%angle = 360 - %theta;
else if(%curX == 0)
{
if(%curY > 0)
%angle = 180;
else if(%curY < 0)
%angle = 360;
else
return false;
}
else if(%curY == 0)
{
if(%curX > 0)
%angle = 90;
else if(%curX < 0)
%angle = 270;
else
return false;
}
%rAngle = %angle - 90;
if(%rAngle < 0)
%rAngle += 360;
%rightPos = %mag * mCos(%rAngle) SPC %mag * mSin(%rAngle) SPC %curZ;
return vectorAdd(%rightPos,%player.getPosition());
}
This code returns a point at a ninety degree angle to where the player is currently looking, presumably to place a brick. By "directly right" I assumed you meant a right angle. The arguments are %player for the player object and %mag, for the distance from the player the object will be.
Important: This code has the point placed at the same height as before. This won't be a problem unless the object you are talking about is way above the player. The object will be at 90 degrees on the XY plane, but when the player leans back they can see the object in periphiral vision. If this is the case, I'll need to append some stuff to the code, but the situation would technically become a bit more complicated than just "to the right of".