Hello Alliedmodders!
After some long research ive been able to create this:
PHP Code:
// v - direction, an - angles
stock vector_to_angles( Float:v[3], Float:an[3] )
{
an[0] = floatsqroot((v[0]*v[0]) + (v[1]*v[1])) / v[2]
an[1] = floatatan(v[1]/v[0], degrees)
}
Problem is that this wont work.
an[0] wont work at all.
an[1] is correct in 180 degrees.
90 > will turn -90 not 91
-90 < will turn 90 not -91
uh. Some much tries and no solution : /
I dont have code for 'angles to vector' yet. Never tried it because working on this stupid thing what eat all my time.
Also. I know there are functions for this but for where i want, cant use those. There are no amxmodx functions.
Edit:
PHP Code:
static cell AMX_NATIVE_CALL vector_to_angle(AMX *amx, cell *params)
{
cell *cAddr = get_amxaddr(amx, params[1]);
REAL fX = amx_ctof(cAddr[0]);
REAL fY = amx_ctof(cAddr[1]);
REAL fZ = amx_ctof(cAddr[2]);
Vector vVector = Vector(fX, fY, fZ);
Vector vAngle = Vector(0, 0, 0);
VEC_TO_ANGLES(vVector, vAngle); // where it came from?
cell *vRet = get_amxaddr(amx, params[2]);
vRet[0] = FloatToCell(vAngle.x);
vRet[1] = FloatToCell(vAngle.y);
vRet[2] = FloatToCell(vAngle.z);
return 1;
}