> 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-weapon-studio/exporting.md).

# Exporting and handing out

Export a weapon skin in CAS Weapon Studio and hand it out. The finishes for metal and wood, selling at gunsmith towns, a job or single players, the 60 skin slots, going live after the next restart and

Export turns a design into real game files. The server builds them inside the resource, in `stream/designs/`. Players see the skin after the next server restart.

{% hint style="warning" %}
After an export, restart the server as you always do. Never restart only this resource while players are online: streamed files that change under a running game can crash clients.
{% endhint %}

## The Export window

Press Export in the top bar. The window is called "Export and hand out".

| Field        | What it is                                                         |
| ------------ | ------------------------------------------------------------------ |
| Name         | The skin's name, 1 to 48 letters. Players read it in the skin book |
| Made for     | The weapon. It cannot be changed here                              |
| Free slots   | How many of the 60 skin slots are free                             |
| Finishes     | How the metal parts and the wood parts catch the light             |
| Hand it out  | Who gets the skin. Pick one or more ways                           |
| What happens | The steps of the export, ticked off as they run                    |

The bottom of the window shows the next restart ("Next restart 06:00, in 2 h 10 min") when you set your restart times. See [Configuration](/script-documentation/cas-weapon-studio/configuration.md#restart-times).

## Finishes

A skin has two finishes: one for its metal parts and one for its wood parts (grips, stocks, forends). The studio shows them live in the 3D preview, and the export writes them into the skin's files as a material map.

| Metal parts | Look                                 |
| ----------- | ------------------------------------ |
| Painted     | Paint over the steel, no metal shine |
| Blued       | Dark oiled steel                     |
| Brushed     | Bare metal with a soft shine         |
| Polished    | Bright plated metal, gold or nickel  |

| Wood parts | Look                        |
| ---------- | --------------------------- |
| Matte      | Dry wood or paint           |
| Oiled      | An oiled stock, ivory, bone |
| Lacquered  | A hard glossy coat, pearl   |

The finishes are kept with the design: when you export it again, the window starts from the last pair. A ready look sets the pair that fits it.

## Hand it out

Tick one or more ways. Each one opens its own settings.

| Way        | Settings                                                    | What the player gets                                                                                 |
| ---------- | ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| Gunsmiths  | A price in dollars (0 to 100000) and the towns that sell it | The skin is for sale in the skin book at the gunsmiths of those towns                                |
| A job      | One or more jobs and "From grade" (0 to 100)                | The skin is free for everyone in that job from that grade. It is in their "My skins" as "your job's" |
| One player | One or more players who are online now                      | The skin goes straight into those characters' "My skins" as "a gift"                                 |

Details:

* The towns are the ones in `Config.Towns`. The jobs are the ones in `Config.Jobs`.
* A price of 0 makes the skin free at the gunsmith.
* A job skin is never stored as owned. When the character leaves the job or drops below the grade, the skin is no longer theirs. It comes off the next time their skins are refreshed, for example when they rejoin or use the book.
* A gift goes to the character, not the account. Take a character off the list and save: the gift is taken back. Skins a player bought stay theirs.
* On a standalone server there are no jobs and nothing is charged.

### Changing the hand-out later

You do not need a new export to change who gets a skin.

1. Open the Saved tab.
2. Press "Hand out" on the design.
3. Change the towns, the price, the jobs or the players.
4. Press "Save the hand out".

The change counts at once. Only live skins are ever sold or worn, so a hand-out on a skin that waits for the restart starts with that restart.

## What happens during an export

| Step                   | Meaning                                                     |
| ---------------------- | ----------------------------------------------------------- |
| Design saved           | The design is stored in the database                        |
| Texture built          | Your game builds the texture from the sheet                 |
| Sent to the server     | The texture travels to the server. A bar shows the progress |
| Written to slot N      | The server writes the skin's files into slot N              |
| Live after the restart | Done                                                        |

The texture is sent at about 64 KB a second so the server does not drop your connection. That is about half a minute for a short arm and about a minute for a long arm. Keep the window open until it is done.

When it ends you read: "Built into slot 3. It goes live at the next restart (06:00)." The server console prints a line too:

```
[cas-weaponstudio] built design 7 as cas_ws_s003 (metal brushed, wood oiled), live after the next restart
```

## Slots

A slot is one place for a live skin. There are 60: `cas_ws_s001` to `cas_ws_s060`.

* Every skin takes one slot from its first export on.
* The studio's bottom line and the Export window show how many are free.
* A deleted skin frees its slot at the next restart.
* An update to a live skin needs a second slot until it has taken over (see below).
* A slot whose texture name another resource already streams is never used. The server console says how many: "2 slot(s) are streamed by another resource and stay unused".

With no slot left, the export stops with: "Every slot is in use. Delete an old design first."

## Live after the next restart

The server never changes files that players are already using, and new files are served from the next server start on. So a skin built now is in the game after the next restart.

| Status                  | Meaning                                         |
| ----------------------- | ----------------------------------------------- |
| WAITING FOR THE RESTART | Built. Not in the game yet. Not sold, not worn  |
| LIVE                    | In the game. Sold and worn as its hand-out says |

Before the restart you can export a waiting skin as often as you like. Each export builds it again in the same slot.

After the restart:

* The skin is LIVE.
* It shows in the skin book of the towns that sell it.
* Players it was handed to find it under "My skins".

## Updating a live skin

You can change a live design and export it again.

1. Open the design from the Saved tab and change it.
2. Press Export, then "Export" in the window.
3. The status becomes UPDATE WAITING. You read: "Update built into slot 9. Players keep the old look until the next restart."
4. After the restart the new look takes over. Every player who owns or wears the skin gets the new look. Nobody has to buy it again.

What to know:

* The update is built into a second, free slot. The old files stay untouched because players are using them. If no slot is free, the update is refused.
* The old slot is free again one restart after the new look has taken over.
* The skin book keeps showing the old name and picture until the new look is live.
* Saving a live design without exporting changes nothing for players.

## Deleting a skin

Delete a design in the Saved tab ("Delete", then "Sure?").

* It leaves the skin book at once and comes off every weapon that wore it.
* Players who bought it lose it. There is no refund.
* Its slot is free again after the next restart.

## What the server writes

For developers and curious owners. All of it is inside `cas-weaponstudio/stream/designs/`:

| File                  | What it is                                               |
| --------------------- | -------------------------------------------------------- |
| `cas_ws_sNNN.ytd`     | The slot's texture and its material map (the finishes)   |
| `cas_ws_sNNN_pKK.ydr` | The weapon's skin parts for that slot, 6 to 14 by weapon |

Do not edit, rename or delete these files by hand. Keep the folder when you replace the resource with a new copy.

## Messages you may see

| Message                                                                                         | What to do                                                                |
| ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| Every slot is in use. Delete an old design first.                                               | Delete a skin you no longer need. Its slot is free after the next restart |
| The upload broke off. Try the export again.                                                     | Export again. An upload that takes longer than 5 minutes is dropped       |
| That slot is in use by the game right now. Export again after the restart.                      | Wait for the restart, then export again                                   |
| The texture encoder did not load (html/bc.js). Rebuild the NUI.                                 | The resource is missing files. Install it again                           |
| This weapon's skin parts are missing on the server (templates/parts). Install the script again. | The `templates` folder is incomplete. Install the resource again          |
| The price must be between 0 and 100000.                                                         | Fix the price                                                             |
| The job grade must be between 0 and 100.                                                        | Fix the grade                                                             |

More in [Troubleshooting](/script-documentation/cas-weapon-studio/troubleshooting.md).
