> For the complete documentation index, see [llms.txt](https://code-after-sex.gitbook.io/script-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://code-after-sex.gitbook.io/script-documentation/cas-sign-and-poster-studio/developers.md).

# For developers

CAS Sign & Poster Studio for developers: how a design becomes a prop, the slots, the files in the resource and the database tables.

## How a design becomes a prop

Every sign shape has a pool of **slots**. A slot is a prop model, `cas_sgn_<shape>_<nnn>` (for example `cas_sgn_board_004`), whose design texture is embedded in its own `.ydr`. The resource ships:

* `stream/cas_signstudio.ytyp`: the archetypes of every slot (260 models, slot `000` of each shape included).
* `stream/cas_sgn_<shape>_000.ydr`: each shape's preview model (the striped stand-in staff see before a design is live).
* `templates/cas_sgn_<shape>_<nnn>.ydr` and `templates/index.json`: every slot's empty model and where each mip of its texture sits inside it.

On export the studio composes the face, compresses it (BC1 for solid shapes, BC3 with transparency for posters and panels, with every mip), and uploads it in small pieces. The server writes the mips into the slot's template and the result into `stream/`. FiveM and RedM serve a resource's stream files from its start on, so the prop shows the design after the next restart.

Files served since the current start are never changed while the server runs: an update of a live design goes into a fresh slot of the same shape and takes over at the next start; the old slot's file is removed when the resource stops.

## The tables

`cas_signstudio_designs`: `id`, `name`, `shape`, `slot_model` (the live slot), `pending_model` (an update waiting for the restart), `layers` (the design, JSON), `thumb`, `status` (`draft`, `waiting`, `live`, `missing`), `owner`, `owner_name`, `business`, `review_at`, `review_note`, `created_at`, `updated_at`.

`cas_signstudio_signs`: `id`, `design_id`, `x`, `y`, `z`, `rx`, `ry`, `rz` (pitch, roll, yaw for `SetEntityRotation` with rotation order 2), and for a sign fixed to an object: `attach_model`, `ax`/`ay`/`az` (where the object stood), `ox`/`oy`/`oz` and `orx`/`ory`/`orz` (the sign's offset and rotation in the object's own frame). Plus `owner`, `owner_name`, `business`, times.

`cas_signstudio_pictures`: `hash`, `data` (pictures inside designs, one row each).

## Spawning

Signs are local objects: every client asks the server for the world list once and gets each new, moved or removed sign as it happens. A client spawns the signs within `Config.SpawnDistance` and removes them beyond it. A sign fixed to an object is attached again whenever that object streams in (`GetClosestObjectOfType` at the stored position).
