SA-MP Forums Archive
get coords of player aiming - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: get coords of player aiming (/showthread.php?tid=312745)



get coords of player aiming - jamesbond007 - 22.01.2012

how do i get the X,Y,Z of the place im looking at ?

in vehicle/ outside vehicle doesnt matter ..

is there any way?


Re: get coords of player aiming - coole210 - 22.01.2012

Look at grappling hook script or something, they check where the player shot and/or is aiming at.


Re: get coords of player aiming - T0pAz - 22.01.2012

pawn Code:
stock IsPlayerAimingAt(playerid, Float:x, Float:y, Float:z, Float:radius) {
  new Float:camera_x,Float:camera_y,Float:camera_z,Float:vector_x,Float:vector_y,Float:vector_z;
  GetPlayerCameraPos(playerid, camera_x, camera_y, camera_z);
  GetPlayerCameraFrontVector(playerid, vector_x, vector_y, vector_z);

    new Float:vertical, Float:horizontal;

    switch (GetPlayerWeapon(playerid)) {
      case 34,35,36: {
      if (DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, vector_x, vector_y, vector_z) < radius) return true;
      return false;
      }
      case 30,31: {vertical = 4.0; horizontal = -1.6;}
      case 33: {vertical = 2.7; horizontal = -1.0;}
      default: {vertical = 6.0; horizontal = -2.2;}
    }

  new Float:angle = GetPointAngleToPoint(0, 0, floatsqroot(vector_x*vector_x+vector_y*vector_y), vector_z) - 270.0;
  new Float:resize_x, Float:resize_y, Float:resize_z = floatsin(angle+vertical, degrees);
  GetXYInFrontOfPoint(resize_x, resize_y, GetPointAngleToPoint(0, 0, vector_x, vector_y)+horizontal, floatcos(angle+vertical, degrees));

  if (DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, resize_x, resize_y, resize_z) < radius) return true;
  return false;
}



Re: get coords of player aiming - jamesbond007 - 23.01.2012

Quote:
Originally Posted by T0pAz
View Post
pawn Code:
stock IsPlayerAimingAt(playerid, Float:x, Float:y, Float:z, Float:radius) {
  new Float:camera_x,Float:camera_y,Float:camera_z,Float:vector_x,Float:vector_y,Float:vector_z;
  GetPlayerCameraPos(playerid, camera_x, camera_y, camera_z);
  GetPlayerCameraFrontVector(playerid, vector_x, vector_y, vector_z);

    new Float:vertical, Float:horizontal;

    switch (GetPlayerWeapon(playerid)) {
      case 34,35,36: {
      if (DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, vector_x, vector_y, vector_z) < radius) return true;
      return false;
      }
      case 30,31: {vertical = 4.0; horizontal = -1.6;}
      case 33: {vertical = 2.7; horizontal = -1.0;}
      default: {vertical = 6.0; horizontal = -2.2;}
    }

  new Float:angle = GetPointAngleToPoint(0, 0, floatsqroot(vector_x*vector_x+vector_y*vector_y), vector_z) - 270.0;
  new Float:resize_x, Float:resize_y, Float:resize_z = floatsin(angle+vertical, degrees);
  GetXYInFrontOfPoint(resize_x, resize_y, GetPointAngleToPoint(0, 0, vector_x, vector_y)+horizontal, floatcos(angle+vertical, degrees));

  if (DistanceCameraTargetToLocation(camera_x, camera_y, camera_z, x, y, z, resize_x, resize_y, resize_z) < radius) return true;
  return false;
}
thanks bro... i will modify it to my needs.. repped