[bot] Implement/match n_IsPlayerInRangeOfPoint(...)

This commit is contained in:
RD42 2024-07-01 23:04:33 +08:00
parent 6de6425aeb
commit 61f5b2ffc4

View File

@ -264,7 +264,28 @@ static cell AMX_NATIVE_CALL n_GetDistanceFromMeToPoint(AMX *amx, cell *params)
// native IsPlayerInRangeOfPoint(playerid, Float:range, Float:X, Float:Y, Float:Z) // native IsPlayerInRangeOfPoint(playerid, Float:range, Float:X, Float:Y, Float:Z)
static cell AMX_NATIVE_CALL n_IsPlayerInRangeOfPoint(AMX *amx, cell *params) static cell AMX_NATIVE_CALL n_IsPlayerInRangeOfPoint(AMX *amx, cell *params)
{ {
// TODO: n_IsPlayerInRangeOfPoint if(!pNetGame->GetPlayerPool()) return 0;
if(!pNetGame->GetPlayerPool()->GetSlotState((PLAYERID)params[1])) return 0;
VECTOR vecTestPoint;
VECTOR vecThisPlayer;
if(pNetGame->GetPlayerPos((PLAYERID)params[1], &vecThisPlayer))
{
float fRange = amx_ctof(params[2]);
vecTestPoint.X = amx_ctof(params[3]);
vecTestPoint.Y = amx_ctof(params[4]);
vecTestPoint.Z = amx_ctof(params[5]);
fRange = fRange * fRange;
float fSX = (vecThisPlayer.X - vecTestPoint.X) * (vecThisPlayer.X - vecTestPoint.X);
float fSY = (vecThisPlayer.Y - vecTestPoint.Y) * (vecThisPlayer.Y - vecTestPoint.Y);
float fSZ = (vecThisPlayer.Z - vecTestPoint.Z) * (vecThisPlayer.Z - vecTestPoint.Z);
if((float)(fSX + fSY + fSZ) <= fRange) return 1;
return 0;
}
return 0; return 0;
} }