Get player near


#1

Hello, I search in forum but I don’t find so I ask you here : I don’t understand how to get the closest player. I want to perform some actions only on a player only if he is near to me but I don’t find how. If you can help me :wink:


#2

Maybe GET_NEAREST_PLAYER_TO_ENTITY will help.


#3

Maybe but I try GetNearestPlayerToEntity(GetPlayerPed(-1)) and it doesn’t work :cry:


#4

I have seen scripts who just check the distance between your position and the player next to you.
(But it only works with /dostuff id commands I guess)


#5

Try with GetClosestPed native function
http://www.dev-c.com/nativedb/func/info/c33ab876a77f8164


#6

I tried but without any documentation is very difficult :cry:


#7

function GetClosestPed(x, y, z, radius, p4, p5, p7, p8, pedType)

Because I’m not sure you can use GetNearestPlayerToEntity for players