Показать сообщение отдельно

  #11  
Старый 04.10.2019, 00:06
Carrentine
Постоянный
Регистрация: 25.12.2018
Сообщений: 568
С нами: 3886298

Репутация: 113


По умолчанию

Описание:находит ближайшего к вашему педу игрока, на определенном радиусе от прицела.

Код:

C++:





[CODE]
void
vect3_copy
(
const
float
in
[
3
]
,
float
out
[
3
]
)
{
memcpy
(
out
,
in
,
sizeof
(
float
)
*
3
)
;
}
float
GetDistance
(
D3DXVECTOR3 target_1
,
D3DXVECTOR3 target_2
)
{
return
sqrt
(
(
target_2
.
x
-
target_1
.
x
)
*
(
target_2
.
x
-
target_1
.
x
)
+
(
target_2
.
y
-
target_1
.
y
)
*
(
target_2
.
y
-
target_1
.
y
)
+
(
target_2
.
z
-
target_1
.
z
)
*
(
target_2
.
z
-
target_1
.
z
)
)
;
}
int
GetNearestPed
(
float
radius
)
{
int
nearestPED
=
-
1
;
float
maxRadius
=
20000.0f
,
currentRadius
;
D3DXVECTOR3 posPed
,
myPosPed
,
screenPos
;
actor_info
*
MyActorInfo
=
SF
->
getSAMP
(
)
->
getPlayers
(
)
->
pLocalPlayer
->
pSAMP_Actor
->
pGTA_Ped
;
vect3_copy
(
MyActorInfo
->
base
.
matrix
+
12
,
myPosPed
)
;
for
(
int
i
=
0
;
i

getSAMP
(
)
->
getPlayers
(
)
->
iIsListed
[
i
]
!=
1
||
SF
->
getSAMP
(
)
->
getPlayers
(
)
->
pRemotePlayer
[
i
]
==
NULL
||
SF
->
getSAMP
(
)
->
getPlayers
(
)
->
pRemotePlayer
[
i
]
->
pPlayerData
==
NULL
||
SF
->
getSAMP
(
)
->
getPlayers
(
)
->
pRemotePlayer
[
i
]
->
pPlayerData
->
pSAMP_Actor
==
NULL
||
SF
->
getSAMP
(
)
->
getPlayers
(
)
->
pRemotePlayer
[
i
]
->
pPlayerData
->
pSAMP_Actor
->
pGTA_Ped
==
NULL
)
continue
;
actor_info
*
ActorInfo
=
SF
->
getSAMP
(
)
->
getPlayers
(
)
->
pRemotePlayer
[
i
]
->
pPlayerData
->
pSAMP_Actor
->
pGTA_Ped
;
vect3_copy
(
ActorInfo
->
base
.
matrix
+
12
,
posPed
)
;
SF
->
getGame
(
)
->
convert3DCoordsToScreen
(
posPed
.
x
,
posPed
.
y
,
posPed
.
z
,
&
screenPos
.
x
,
&
screenPos
.
y
)
;
static
float
iX
=
GetSystemMetrics
(
SM_CXSCREEN
)
*
0.5299999714f
;
static
float
iY
=
GetSystemMetrics
(
SM_CYSCREEN
)
*
0.4f
;
if
(
(
(
abs
(
iX
-
screenPos
.
x
)
)
>
radius
)
||
(
(
abs
(
iY
-
screenPos
.
y
)
)
>
radius
)
)
continue
;
currentRadius
=
GetDistance
(
myPosPed
,
posPed
)
;
if
(
currentRadius



Пример:

C++:





[CODE]
int
id
=
GetNearestPed
(
100
)
;
if
(
id

 
Ответить с цитированием