Do something when next to a specific object

Hi,
if I know the model hash of an item, how can I check its distance to the player ?

Imagine you want the player to do a specific anim when you get close to a specific object.
Considering there’s hundreds of that item around the map, how can you check for that item but inside
a certain radius ?

I’d like to have something like this :


local playerPos = GetEntityCoords(GetPlayerPed(-1), true)
local itemPos = GetEntityCoords(prop_mailbox_3, true)

if distance  < 1.0 then ...

Something like (not tested but should give you the idea):

local distance = GetDistanceBetweenCoords(playerPos["x"], playerPos["y"], playerPos["z"], 
itemPos["x"], itemPos["y"], itemPos["z"], true)

if distance < 1 then...

Thanks, I know how to calculate the distance but I guess I didn’t formulate my question properly.

Imagine you want the player to do a specific anim when you get close to a specific object.
Considering there’s hundreds of that item around the map, how can you check for that item but inside
a certain radius ?

e.g As the player walks around the map, I’d like to check if there’s a mailbox prop close to him. If so, get the distance to that mailbox.