questionCustom App Usage

# GetCurrentTabletData – Usage Guide

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.

---

## 1. What `GetCurrentTabletData` does

The export:

```lua
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:

  • 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).


If you also want to fetch the cloud gallery for the active tablet owner, use the includeGallery option:

When includeGallery = true, tablet.gallery is a list of rows based on the 0r_tablet_gallery table, typically:

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:

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:


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:

  • includeGallery = true triggers 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.

Last updated