> 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-clothing-studio/installation.md).

# Installation

Install CAS Clothing Studio on a RedM server: requirements, server.cfg, staff access, restart times, AI Design keys and the database tables.

## What you need

* A RedM server with **oxmysql**.
* **VORP Core** or **RSG Core** for characters, money and jobs. The Studio also runs standalone.
* Nothing else: no CodeWalker, no OpenIV, no external tools.

For players to buy and wear designs, one of these clothing stores:

* **CAS Character Creator**, 2.1.0 or newer (the update that adds the Designs row). Works out of the box.
* **vorp\_character** with the [vorp\_character patch](/script-documentation/cas-clothing-studio/vorp-character.md).
* **rsg-appearance** 2.5.6 with the [rsg-appearance patch](/script-documentation/cas-clothing-studio/rsg-appearance.md).
* Or none of them: the Studio's own tailor counters then sell and dress the designs. See [Where players get designs](/script-documentation/cas-clothing-studio/clothing-stores.md).

## Steps

1. Put the `cas-clothingstudio` folder in your `resources` folder.
2. Add it to `server.cfg`, after oxmysql and your framework:

```cfg
ensure oxmysql
# ... your framework and your clothing script (cas-charcreator, vorp_character or rsg-appearance) ...
ensure cas-clothingstudio

# who may open the studio (framework admin groups in config.lua work too)
add_ace group.admin cas.clothingstudio allow

# when your server restarts (server local time); shown as "live after the next restart"
set cs_restart_times "06:00,18:00"

# optional: AI Design with your own key (fal, google or openai)
set cs_ai_provider "fal"
set cs_ai_key "YOUR_KEY"
# set cs_ai_model ""   (only to use another model than the default)
```

3. Set the towns, the language and the rest in `config.lua`. See [Configuration](/script-documentation/cas-clothing-studio/configuration.md).
4. Start the server. With a supported clothing script running, the console shows a line like:

```
[cas-clothingstudio] clothing script integrated: cas-charcreator
```

The start order of `cas-clothingstudio` and your clothing script does not matter.

{% hint style="info" %}
Keep the AI key in `server.cfg`, never in `config.lua`. The key stays on the server; players never see it.
{% endhint %}

## The database

The four tables are made on the first start:

| Table                   | What it holds                                       |
| ----------------------- | --------------------------------------------------- |
| `cas_clothing_designs`  | The designs: garment, layers, name, slot and status |
| `cas_clothing_pictures` | The pictures in a design (AI answers, uploads)      |
| `cas_clothing_handout`  | How each design is handed out: shops, jobs, players |
| `cas_clothing_owned`    | Which character owns which design, and what is worn |

Pictures are stored one per row, so each query stays well under 1 MB, XAMPP's default `max_allowed_packet`.

{% hint style="warning" %}
If saving a design says the database refused it, raise the limit in MySQL's `my.ini` under `[mysqld]`: `max_allowed_packet=16M`, then restart MySQL.
{% endhint %}

## After an export

A new or changed design reaches players only after a server restart, and players must rejoin to load it.

{% hint style="danger" %}
Never restart `cas-clothingstudio` on its own while players are online after an export. Streamed files that change under a running game can crash clients. Wait for the server's restart.
{% endhint %}
