Skip to content

GetNearestSmartObject

The nearest free seat, bed or work spot.

The first of GetSmartObjects(x, y, z, radius, use, true).

GetNearestSmartObject(x, y, z [, radius, use])
Parameter Type
x number metres
y number metres
z number metres
radius number metres (10 when not given) (optional)
use string | nil an activity, a kind or a helper class (optional)

table | nil - the object’s table as GetSmartObjects gives it; nil when none is free in reach

local spot = GetNearestSmartObject(1260, 1080, 26, 30, "work")
if spot then SetActorUse(peasant, spot.key) end

GetSmartObjects · SetActorUse · the Actor life group of the index