25.02.2015, 19:38
How do i get the point on the ground (im using map andreas) where the plane that im flying is heading to?
GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance) { // Created by ****** 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)); }
#include <a_samp>
#include "VehicleMatrix.inc"
main(){}
stock IsAFlyingVehicle(vehicleid)
{
switch(GetVehicleModel(vehicleid))
{
case
460,464,476,511,512,513,519,520,553,577,592,593,//flying vehicle models
417,425,447,465,469,487,488,497,501,548,563:
return true;
}
return false;
}
stock GetPlaneHitPoint(playerid, &Float:hx, &Float:hy)
{
if(!IsAFlyingVehicle(GetPlayerVehicleID(playerid)))return 0;
new Float:pos[2][3];
GetVehiclePos(GetPlayerVehicleID(playerid),pos[0][0],pos[0][1],pos[0][2]);
PositionFromVehicleOffset(GetPlayerVehicleID(playerid),0.0,250.0,0.0,pos[1][0],pos[1][1],pos[1][2]);
return checkpls(0,pos[0][0],pos[0][1],pos[0][2],pos[1][0],pos[1][1],pos[1][2], hx, hy);
}
stock checkpls(initiatore,Float:StartX,Float:StartY,Float:StartZ,Float:EndX,Float:EndY,Float:EndZ, &Float:hhx, &Float:hhy)
{
new Float:AdderX = (EndX-StartX)/12.0;
new Float:AdderY = (EndY-StartY)/12.0;
new Float:AdderZ = (EndZ-StartZ)/12.0;
new Float:sz;
for(new i = 0, Float:x = 0.0; i < 12; ++i, x += 1.0)
{
MapAndreas_FindZ_For2DCoord(StartX+(AdderX*x),StartY+(AdderY*x), sz);
if(sz >= StartZ+(AdderZ*x))
{
hhx = StartX+(AdderX*x);
hhy = StartY+(AdderY*x);
return true;
}
}
return false;
}
new Float:mx, Float:my;
if(GetPlaneHitPoint(playerid, mx, my))
{
//ok now ground hit points stored in mx and my use it for whatever you want
}
else
{
//plane is either too high or its nose direction is not pointing at ground
//or plane is not hitting the ground if it moves in same direction at range of 250.0
//or the vehicle in which player is not a plane
}
pawn Код:
|