Skip to content

tm_lib's own scripts ​

Most of tm_lib is imports that run inside the resource that asks for them. A few things have to live in tm_lib itself because they are shared by every resource or need one owner. They load from resource/ and do nothing until something uses them.

ScriptWhat it doesCost while unused
resource/grids/client.lua, server.luaThe grid tracker behind tm.grids.onEnter / onExit, see tm.grids. Reference counted per resource and cell size, released when a resource stops.No thread, no reads.
resource/grids/debug.lua/tmgrids, a staff only display of the grid cells around you.A command and nothing else.
resource/staff/client.lua, server.luaPushes the staff answer to each client for tm.staff on the client.One event per login or job change.
resource/ped/client.luaFinishes server peds (tm.ped.create on the server) for resources that did not import tm.ped on their client: invincible when static, name tag, then the acknowledgement. It waits 1.5 seconds so the creating resource's own handler goes first, and it only acts for peds this client owns.A state bag handler.
resource/entity/client.lua, server.luaEntity cleanup by state bag. Set cleanupEntity to true on a networked ped, vehicle or object and the client that controls it deletes it at once. The server also deletes it once no client owns it, or after N milliseconds when the value is a number. Players' peds are never touched.A state bag handler. One sweeper thread only while something waits.
resource/time/server.luaThe tm_lib:getTime callback: the server's os.time() for clients, which have no os library. tm.callback.await('tm_lib:getTime').None.
lua
-- the server clock, from a client thread
local now = tm.callback.await('tm_lib:getTime')

-- delete a ped when nobody controls it any more, or after a minute at the latest
Entity(ped).state:set('cleanupEntity', 60000, true)