Problem In X Y Z In Front Of Player
#1

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;

    }
}
Now That Doesn't Work In All Cases of rx i dunno why can anybody help me ??
Reply
#2

Hello try it on callbacks

PHP код:
forward GetXYZInFrontOfPlayer(playerid, &Float:x, &Float:y, &Float:zFloat:distance);
public 
GetXYInFrontOfPlayer(playerid, &Float:x, &Float:yFloat:distance)
{
    new 
Float:a;
    
GetPlayerPos(playeridxya);
    
GetPlayerFacingAngle(playerida);
    if (
GetPlayerVehicleID(playerid))
    {
        
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    }
    
+= (distance floatsin(-adegrees));
    
+= (distance floatcos(-adegrees));
}
forward GetXYZInFrontOfPlayer(playerid, &Float:x, &Float:y, &Float:zFloat:distance);
public 
GetXYZInFrontOfPlayer(playerid, &Float:x, &Float:y, &Float:zFloat:distance)
{
    if(!
IsPlayerInAnyVehicle(playerid))
    {
        new 
Float:a;
        
GetPlayerPos(playeridxyz);
        
GetPlayerFacingAngle(playerida);
        
+= (distance floatsin(-adegrees));
        
+= (distance floatcos(-adegrees));
    }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(playeridxyz);
        new 
Float:dist2,Float:dist3;
        
dist2 = (floatcos(-rxdegrees) * distance);
        
dist3 = (floatsin(-rxdegrees) * distance);
        
GetXYInFrontOfPlayer(playerid,x,y,dist2);
        
+= dist3;
    }

Reply
#3

nope still as it is
Reply
#4

Anyone ?? Sorry For Bumping But 4 or 5 days without any reply ??
And For Clearing It Out

This Is A 2D Trigonometry But In A 3D World.
I Need X2 Y2 Z2 .I Have Distance D , Point A (X,Y,Z), Angle O
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)