mirror of
https://github.com/dashr9230/SA-MP.git
synced 2025-09-20 12:46:07 +08:00
[bot] Implement/match n_GetDistanceFromMeToPoint(...)
* Implement/match `CNetGame::GetDistanceFromMeToPoint(...)`
This commit is contained in:
@ -250,6 +250,23 @@ BOOL CNetGame::IsVehicleAdded(VEHICLEID VehicleID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
float CNetGame::GetDistanceFromMeToPoint(PVECTOR vecPos)
|
||||||
|
{
|
||||||
|
VECTOR vecMyPos;
|
||||||
|
|
||||||
|
if(GetMyPos(&vecMyPos))
|
||||||
|
{
|
||||||
|
float fX = vecMyPos.X - vecPos->X;
|
||||||
|
float fY = vecMyPos.Y - vecPos->Y;
|
||||||
|
float fZ = vecMyPos.Z - vecPos->Z;
|
||||||
|
|
||||||
|
return (float)sqrt(fX * fX + fY * fY + fZ * fZ);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
PVECTOR CNetGame::GetMyPos(PVECTOR Vector)
|
PVECTOR CNetGame::GetMyPos(PVECTOR Vector)
|
||||||
|
@ -114,6 +114,7 @@ public:
|
|||||||
BYTE GetPlayerSpecialAction(PLAYERID playerId);
|
BYTE GetPlayerSpecialAction(PLAYERID playerId);
|
||||||
BOOL IsPlayerAdded(PLAYERID playerId);
|
BOOL IsPlayerAdded(PLAYERID playerId);
|
||||||
BOOL IsVehicleAdded(VEHICLEID VehicleID);
|
BOOL IsVehicleAdded(VEHICLEID VehicleID);
|
||||||
|
float GetDistanceFromMeToPoint(PVECTOR vecPos);
|
||||||
PVECTOR GetMyPos(PVECTOR Vector);
|
PVECTOR GetMyPos(PVECTOR Vector);
|
||||||
void SetMyPos(PVECTOR Vector);
|
void SetMyPos(PVECTOR Vector);
|
||||||
float GetMyZAngle();
|
float GetMyZAngle();
|
||||||
|
@ -306,8 +306,20 @@ static cell AMX_NATIVE_CALL n_SetMyFacingAngle(AMX *amx, cell *params)
|
|||||||
// native GetDistanceFromMeToPoint(Float:X, Float:Y, Float:Z, &Float:Distance)
|
// native GetDistanceFromMeToPoint(Float:X, Float:Y, Float:Z, &Float:Distance)
|
||||||
static cell AMX_NATIVE_CALL n_GetDistanceFromMeToPoint(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL n_GetDistanceFromMeToPoint(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
// TODO: n_GetDistanceFromMeToPoint
|
if(!pNetGame->GetPlayerPool()) return 0;
|
||||||
return 0;
|
|
||||||
|
VECTOR vecPos;
|
||||||
|
vecPos.X = amx_ctof(params[1]);
|
||||||
|
vecPos.Y = amx_ctof(params[2]);
|
||||||
|
vecPos.Z = amx_ctof(params[3]);
|
||||||
|
|
||||||
|
float fResult = pNetGame->GetDistanceFromMeToPoint(&vecPos);
|
||||||
|
|
||||||
|
cell* cptr;
|
||||||
|
amx_GetAddr(amx, params[4], &cptr);
|
||||||
|
*cptr = amx_ftoc(fResult);
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// native IsPlayerInRangeOfPoint(playerid, Float:range, Float:X, Float:Y, Float:Z)
|
// native IsPlayerInRangeOfPoint(playerid, Float:range, Float:X, Float:Y, Float:Z)
|
||||||
|
Reference in New Issue
Block a user