19.04.2012, 01:09
Code:
/*
Float:offset_x - the distance between the Vehicle and the attached object in the X direction.
Float:offset_y - the distance between the Vehicle and the attached object in the Y direction.
Float:offset_z - the distance between the Vehicle and the attached object in the Z direction.
Float:x - the variable to store the X coordinate
Float:y - the variable to store the Y coordinate
Float:z - the variable to store the Z coordinate
*/
stock GetAttachedObjectPosFromVehicle(vehicleid, Float:offset_x, Float:offset_y, Float:offset_z, &Float:x, &Float:y, &Float:z)
{
new Float:deg;
new Float:s;
new Float:objectangle;
new Float:pos[3];
GetVehicleZAngle(vehicleid, deg);
GetVehiclePos(vehicleid, pos[0], pos[1], pos[2]);
s = floatsqroot(offset_x * offset_x + offset_y * offset_y);
objectangle = atan(offset_y / offset_x);
deg += 90.0;
deg += objectangle;
if(offset_x < 0 )
{
x = pos[0] + s * floatsin(-deg, degrees);
y = pos[1] + s * floatcos(-deg, degrees);
z = pos[2] + offset_z;
}
else
{
x = pos[0] + s * floatsin(180.0-deg, degrees);
y = pos[1] + s * floatcos(180.0-deg, degrees);
z = pos[2] + offset_z;
}
}

