mirror of
https://github.com/dashr9230/SA-MP.git
synced 2025-09-19 20:26:14 +08:00
[saco] Implement/match CEntity::Get2DDistanceFromLocalPlayerPed()
This commit is contained in:
@ -280,6 +280,38 @@ float CEntity::GetDistanceFromCamera()
|
||||
|
||||
//-----------------------------------------------------------
|
||||
|
||||
float CEntity::Get2DDistanceFromLocalPlayerPed()
|
||||
{
|
||||
MATRIX4X4 matFromPlayer;
|
||||
MATRIX4X4 matThis;
|
||||
float fSX,fSY,fSZ;
|
||||
|
||||
CPlayerPed *pLocalPlayerPed = pGame->FindPlayerPed();
|
||||
CLocalPlayer *pLocalPlayer=NULL;
|
||||
|
||||
if(!pLocalPlayerPed) return 10000.0f;
|
||||
|
||||
GetMatrix(&matThis);
|
||||
|
||||
if(pNetGame) {
|
||||
pLocalPlayer = pNetGame->GetPlayerPool()->GetLocalPlayer();
|
||||
if(pLocalPlayer && (pLocalPlayer->IsSpectating() || pLocalPlayer->IsInRCMode())) {
|
||||
pGame->GetCamera()->GetMatrix(&matFromPlayer);
|
||||
} else {
|
||||
pLocalPlayerPed->GetMatrix(&matFromPlayer);
|
||||
}
|
||||
} else {
|
||||
pLocalPlayerPed->GetMatrix(&matFromPlayer);
|
||||
}
|
||||
|
||||
fSX = (matThis.pos.X - matFromPlayer.pos.X) * (matThis.pos.X - matFromPlayer.pos.X);
|
||||
fSY = (matThis.pos.Y - matFromPlayer.pos.Y) * (matThis.pos.Y - matFromPlayer.pos.Y);
|
||||
|
||||
return (float)sqrt(fSX + fSY);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
|
||||
float CEntity::GetDistanceFromPoint(float X, float Y, float Z)
|
||||
{
|
||||
MATRIX4X4 matThis;
|
||||
|
@ -27,6 +27,7 @@ public:
|
||||
void TeleportTo(float x, float y, float z);
|
||||
float GetDistanceFromLocalPlayerPed();
|
||||
float GetDistanceFromCamera();
|
||||
float Get2DDistanceFromLocalPlayerPed(); // unused
|
||||
|
||||
float GetDistanceFromPoint(float X, float Y, float Z);
|
||||
BOOL IsStationary();
|
||||
|
Reference in New Issue
Block a user