16.12.2013, 18:46
pawn Код:
#include <a_samp>
#include <QuaternionStuff>
#include <zcmd>
GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
if (GetPlayerVehicleID(playerid))
{
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}
GetXYZInFrontOfPlayer(playerid, &Float:x, &Float:y, &Float:z, Float:distance)
{
if(!IsPlayerInAnyVehicle(playerid))
{
new Float:a;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}else{
new Float:qw,Float:qx,Float:qy,Float:qz,Float:rx,Float:ry,Float:rz,Float:a;
GetVehicleRotationQuat(GetPlayerVehicleID(playerid),qw,qx,qy,qz);
QuatToEuler(rx,ry,rz,qw,qx,qy,qz);
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
GetPlayerPos(playerid, x, y, z);
new Float:dist2,Float:dist3;
dist2 = (floatcos(-rx, degrees) * distance);
dist3 = (floatsin(-rx, degrees) * distance);
GetXYInFrontOfPlayer(playerid,x,y,dist2);
z += dist3;
}
}