st.waitFor — Async Polling Helper
Yields the current coroutine until cb returns a non-nil value.
lua
---@param cb function Returns nil to keep waiting, any other value to resolve
---@param errMessage string? Error if timeout is reached
---@param timeout? number | false Milliseconds to wait (default 1000, false = infinite)
---@return any The first non-nil value returned by cb
local value = st.waitFor(function()
return GetVehiclePedIsIn(cache.ped, false) -- returns 0 while not in vehicle
end, 'Timed out waiting for vehicle', 5000)