Author Topic: How to align player to north/south/east/west through console  (Read 625 times)

I know there's a way to do this and I know you can use $mvYaw, but I don't know how to make it align exactly with north/south/east/west. Can someone help please?

Client sided or server sided?


Here is a function I wrote a while back that will make your player look at a point.
Hopefully this helps.

Code: [Select]
function lookat(%posb)
{
%posa = serverconnection.getcontrolobject().getposition();
%xa = getword(%posb, 0) - getword(%posa, 0);
%ya = getword(%posb, 1) - getword(%posa, 1);
%za = getword(%posb, 2) - getword(%posa, 2) - getword(serverconnection.getcontrolobject().getdatablock().boundingbox, 2)/5 + $iamcrouching*1.5;
%la = msqrt(mpow(%xa, 2) + mpow(%ya, 2) + mpow(%za, 2));
%pitcha = macos(%za/%la);
%yawa = matan(%xa, %ya);

%v = serverconnection.getcontrolobject().getmuzzlevector(0);
%xb = getword(%v, 0);
%yb = getword(%v, 1);
%zb = getword(%v, 2);
%pitchb = macos(%zb);
%yawb = matan(%xb, %yb);

%pitch = %pitcha - %pitchb;
%yaw = %yawa - %yawb;

$mvpitch = %pitch;
$mvyaw = %yaw;
}

This might also be useful:

Code: [Select]
//0 - East
//1 - South
//2 - West
//3 - North
function getplayerdirection()
{
if(isObject(%p = serverconnection.getcontrolobject()))
{
%va = getword(%p.getforwardvector(),0);
%vb = getword(%p.getforwardvector(),1);

if(mabs(%va) > mabs(%vb))
{
if(%va > 0)
return 0;
else
return 2;
}
else
{
if(%vb > 0)
return 1;
else
return 3;
}
}
else
return 4;
}