GetCurrentTabletData#
This document explains how to use the GetCurrentTabletData export provided by 0r-smarttab to access the currently open tablet’s data (including gallery photos) from any client-side Lua resource.
local tablet = exports['0r-smarttab']:GetCurrentTabletData(options)
returns a Lua table that describes the tablet currently open for the local player.
Base shape:
{
isOpen = boolean, -- whether the tablet UI is currently open
serial = string|nil, -- active tablet serial, or nil if none
gallery = table|nil, -- optional, only when requested
}
You can call this from any client-side script as long as 0r-smarttab is running.
2. Basic usage#
Minimal example:
local tablet = exports['0r-smarttab']:GetCurrentTabletData()
if tablet.isOpen and tablet.serial then
print(("[SmartTab] Current tablet serial: %s"):format(tablet.serial))
else
print("[SmartTab] No tablet is currently open.")
end
tablet.isOpen→ whether the player currently has the tablet open.tablet.serial→ serial number of the active tablet (useful as a key in your own systems/DB).
3. Including gallery data#
If you also want to fetch the cloud gallery for the active tablet owner, use the includeGallery option:
local tablet = exports['0r-smarttab']:GetCurrentTabletData({ includeGallery = true })
if tablet.isOpen and tablet.serial then
print("Current tablet serial:", tablet.serial)
if tablet.gallery then
print("Gallery items:", #tablet.gallery)
for i, photo in ipairs(tablet.gallery) do
print(("[#%d] url=%s type=%s favorite=%s"):format(
i,
photo.url or photo.image or "nil",
tostring(photo.type or "unknown"),
tostring(photo.is_favorite)
))
end
end
end
When includeGallery = true, tablet.gallery is a list of rows based on the 0r_tablet_gallery table, typically:
{
id = number,
tablet_serial = string,
image = string, -- stored image field
url = string, -- same as image, provided for UI convenience
type = string, -- e.g. "photo", "screenshot", etc.
is_favorite = boolean,
album_id = string|nil,
created_at = string|nil,
}
You can pass photo.url directly to your NUI or reuse it for your own mini-galleries / pickers.
4. Typical use cases#
4.1 Custom apps#
Inside a custom app’s client.lua:
local tablet = exports['0r-smarttab']:GetCurrentTabletData({ includeGallery = true })
if tablet.isOpen and tablet.serial then
-- attach your own data to this serial
-- e.g. load job-specific info, tickets, etc.
if tablet.gallery then
-- show a custom gallery in your own NUI
end
end
Use cases:
- Show the player’s gallery inside your own app UI.
- Filter photos by type or album.
- Use the serial as a key for app-specific data.
4.2 Job / utility scripts#
Any job script can:
- Check whether a tablet is currently open before performing actions.
- Link actions or logs to the active tablet serial instead of (or in addition to) player ID.
Example:
RegisterCommand('tabletdebug', function()
local tablet = exports['0r-smarttab']:GetCurrentTabletData({ includeGallery = true })
print(json.encode(tablet, { indent = true }))
end, false)
5. Notes and caveats#
-
The export is client-side only. Call it from client scripts, not from server code.
-
If no tablet is open, you will always get at least:
{ isOpen = false, serial = nil } -
includeGallery = truetriggers an async callback internally and waits for it; avoid calling it every frame. It’s intended for on-demand usage (e.g. when opening your custom app UI or pressing a key).
This export is designed to make it easy for custom apps and other resources to integrate with the tablet ecosystem and reuse existing tablet data (especially gallery photos) without duplicating logic.