getNearestObjectOfType

Finds the nearest object of a specific type/model.

Parameters:

  • type (hash): The model hash of the object type to search for

  • distance (number, optional): Maximum search distance in units. Defaults to 10.0.

  • coords (vector3, optional): The coordinates to search from. Defaults to player's current position.

Returns:

  • object (entity): The nearest object of the specified type, or 0 if none found

Example:

local propHash = GetHashKey("prop_atm_01")
local atm = ps.getNearestObjectOfType(propHash, 5.0)
if atm ~= 0 then
    print("Found ATM nearby")
end

Last updated