Exports & events
Server exports
Lua
exports['saf-tv']:GetPlacedTvs() -- every placed TV
exports['saf-tv']:RemovePlacedTv(uid, src) -- remove one, optionally giving the item back to srcGetPlacedTvs returns a list with one entry per TV:
| Field | What it is |
|---|---|
uid | Id of the placed TV |
item | Item it was placed from, e.g. 'tv_large' |
model | Prop model |
coords | vector3 position |
heading | Heading in degrees |
owner | Character id of the player who placed it |
ownerName | Their character name |
RemovePlacedTv returns true when the TV existed and was removed. Leave src out to remove it without
giving the item back.
Example: clear TVs from a property
Lua
-- in your own server resource
local function clearTvsNear(center, radius)
for _, tv in ipairs(exports['saf-tv']:GetPlacedTvs()) do
if #(tv.coords - center) < radius then
exports['saf-tv']:RemovePlacedTv(tv.uid)
end
end
endItem export
ox_inventory uses an item export to start placing a TV. The lines in install/ox_inventory.txt already set it:
Lua
['tv_large'] = {
label = 'Big Screen TV',
weight = 15000,
stack = false,
close = true,
server = { export = 'saf-tv.useTvItem' },
},Other inventories go through the framework's usable items, handled by Bridge.RegisterUsableItem.