Skip to content

Wait for access (tm.waitForAccess) ​

Client side only. Requests network control of an entity and waits until it is granted, so you can delete, move or change networked properties of an entity you do not own yet.

lua
local ok = tm.waitForAccess(vehicle, 2000)
if ok then
    DeleteEntity(vehicle)
else
    tm.log.warn('could not get network control of the vehicle')
end

tm.waitForAccess(entity, timeout?) ​

ArgumentTypeDescription
entityintegerEntity handle.
timeoutinteger?Milliseconds to wait, default 5000.

Returns true when this client has control at the end, false otherwise.

  • It calls NetworkRequestControlOfEntity every 20 ms until NetworkHasControlOfEntity is true or the timeout passes.
  • It returns false at once for entity 0 or an entity that does not exist, and also when the entity disappears during the wait.
  • A timeout of 0 does not wait. It checks and returns the current ownership state without requesting control.
  • It yields, so call it from a thread.