GetNearestObjectToLocation(int, location, int)
Returns the nearest object, which is of a specified type, to a given location.
Location to find a nearby object from.
Which object to find. (Default: 1)
Get the nNth object nearest to lLocation that is of the specified type.
Return value on error: OBJECT_INVALID
The function selects the Nth (default is 1, i.e. nearest) nearest object that is of a certain type to the given location. By default âtypeâ is set to OBJECT_TYPE_ALL, therefore the function will return the Nth nearest valid object to a given location by simply passing a location value to the function, unless you specify a âtypeâ in the form OBJECT_TYPE_*. You can 'or' several OBJECT_TYPE_* constants together using the bitwise | (or) operator. See code sample below.
It seems that this function returns OBJECT_INVALID if the location of the object is identical to the location passed to the function. In other words, if there is an object at the exact location that is fed into the function it will NOT be returned by the function. Simply put, the function does not consider an identical location to be the nearest location.
1.64 made sure this function is now consistant - it will return the nearest objects every time it is called from the same location.
author: Jason Simpson, editor: Jasperre, additional contributor(s): Lilac Soul, Heed, Jasperre