first and foremost why the hell are you using the actual function clientCmdCenterPrint?
commandToClient(%client, 'centerPrint', "foobar.", 3);
OR
%client.centerPrint("foobar.", 3);
clientCmdCenterPrint only works with the actual client the mod is installed on. If you try this on a dedicated server even the message will not work.
I'm getting tired of trying to find the problem in your code so here's what should work.
// Learn to camel-case.
function serverCmdObjTest(%client)
{
// Get the player.
%obj = %client.player;
// If they don't have a player we can't do anything.
if(!isObject(%obj))
{
%client.centerPrint("\c5Spawn first, dummy.", 2);
return;
}
// Space Guy's code (iban no good at math)
// Used to figure out in which direction the player is looking.
%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;
// Our range is the maximum that is stable for raycasts.
%range = 100;
// Multiple the aimvec and add it to our starting position to get an end point.
%end = vectorAdd(%start, vectorScale(%aimVec, %range));
// Masks
// AlwaysObjectType will hit non-raycasting bricks, too.
%masks = $TypeMasks::FxBrickAlwaysObjectType;
// Get the collision object of the raycast.
%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());
}
If you have any other problems, make a new thread. This is "Iban Explains it All" not "Treynolds416 gets people to resolve his scripts for him."