> 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/troubleshooting.md).

# Troubleshooting

CAS Weapon Studio troubleshooting for RedM. A skin that does not show before a restart, the restart rule, no free slot, a part the skin does not cover, AI Design off, the database packet size and the

## A skin does not show after the export

This is how the script works. An exported skin is in the game after the next server restart, not before.

| What you see                                                           | Meaning                                              |
| ---------------------------------------------------------------------- | ---------------------------------------------------- |
| Status WAITING FOR THE RESTART                                         | The files are built. The skin is not in the game yet |
| The skin is not in the skin book                                       | Only live skins are sold and worn                    |
| "This skin is not in the game yet. It arrives after the next restart." | The same, said to a player                           |

What to do: restart the server as you always do. After the start the status is LIVE and the skin is in the book.

Set your restart times so the studio can tell staff when that is: `set ws_restart_times "06:00,18:00"`.

## Never restart only this resource with players online

{% hint style="warning" %}
After an export, do not `restart cas-weaponstudio` or `ensure cas-weaponstudio` while players are online. Streamed files that change under a running game can crash clients. Restart the server.
{% endhint %}

Why: the skins are streamed game files. A player's game has the files of the last server start loaded. A resource restart after an export serves new and changed files to games that are still running.

What is safe:

* A full server restart, where every player rejoins.
* Restarting the resource while no player is connected.

The script itself is careful: while the server runs it never writes or deletes a file that is already being served. Removed skins are cleaned up when the resource stops.

## "Every slot is in use. Delete an old design first."

All 60 skin slots are taken.

| Cause                                                  | What to do                                                                                                                     |
| ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ |
| 60 designs were exported                               | Delete a design you no longer need in the Saved tab. Its slot is free after the next restart                                   |
| You deleted a design but the count did not go up       | The slot is free only after the next restart                                                                                   |
| You exported an update to a live skin                  | An update needs a second slot until the restart. The old slot is free one restart after the new look took over                 |
| Another resource streams a texture named `cas_ws_sNNN` | The server console says "N slot(s) are streamed by another resource and stay unused". Remove that file from the other resource |

The studio's bottom line and the Export window show how many slots are free.

## A part of the weapon is not covered

A skin covers the weapon's body, its moving parts (cylinder, hammer, lever, trigger) and the standard and shop grips, barrels, stocks and forends.

| What you see                                                 | Why                                                                                                                                        |
| ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
| Scopes, sights, wraps or cartridges keep their own look      | They are not part of a skin. This is by design                                                                                             |
| A spot on the gun shows the game's own surface               | The sheet is clear there. Add a Base colour that covers the Whole gun, or paint that spot                                                  |
| The skin on a pump-action forend stays still during a reload | Known: a gunsmith part that hangs on a moving part keeps its skin in place while the part moves. Code only, not verified in game           |
| One grip, barrel, stock or forend has no skin                | Skin parts exist for the standard and shop parts the script knows for each weapon. `/ws_test info` shows which of them your weapon carries |
| Nothing shows at all on one weapon                           | Check `Config.Weapons`: `enabled = false` turns drawing off for that weapon                                                                |

To check the files of one slot without the book, set `Config.Debug = true` on a test server and use `/ws_test on <slot>` with the weapon in your hand. `/ws_test info` lists the gunsmith parts the weapon carries. See [Commands](/script-documentation/cas-weapon-studio/commands.md).

## A skin shows NEEDS EXPORT

The skin was live, but its files in `stream/designs/` are gone. The server console says: `design 7 (Marshal's Pride) lost its files in stream/: export it again`.

This happens when the resource folder was replaced without keeping `stream/designs/`.

What to do: open the design and export it again. It is live after the next restart. Until then it is not sold and not shown. When you replace the resource with a new copy, keep `stream/designs/`.

## AI Design is off

The studio's bottom line says "AI off", and the AI window says "AI Design is off: set ws\_ai\_provider and ws\_ai\_key in server.cfg".

1. Set both convars in `server.cfg`:

```cfg
set ws_ai_provider "fal"
set ws_ai_key "YOUR_KEY"
```

2. The provider must be `fal`, `google` or `openai`, written exactly so.
3. Restart. The bottom line then says "AI: fal".

AI Design is optional. Everything else works without it.

| Message                                                                                  | Meaning                                                                                       |
| ---------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| AI Design is not set up on this server.                                                  | No provider or no key                                                                         |
| The AI key was refused. Check ws\_ai\_key.                                               | The provider did not accept the key                                                           |
| The AI account is out of credit. The server owner needs to top it up at the AI provider. | The key is right, the account has no balance                                                  |
| The AI provider says slow down or the quota is used up.                                  | The provider's rate limit or quota                                                            |
| The AI took too long. Try again.                                                         | No answer within 150 seconds                                                                  |
| Another AI request is running. Try again in a moment.                                    | One request at a time for the whole server                                                    |
| Wait a few seconds between AI requests.                                                  | The same staff member asked twice within a few seconds                                        |
| Describe the look first.                                                                 | The description is empty, or longer than 1500 letters                                         |
| The AI request failed (...).                                                             | Another error. The server console has a line that starts with `ai:` and the provider's answer |

## The database refused the design

Message: "The database refused the design. Raise max\_allowed\_packet in MySQL (16M or more), or use smaller pictures."

MySQL refuses a query that is larger than `max_allowed_packet`. XAMPP ships with 1 MB. The studio stores pictures one per row to stay under that, but a design with many layers can still be too large.

Raise the limit in `my.ini` (or `my.cnf`) under `[mysqld]`, then restart MySQL:

```ini
[mysqld]
max_allowed_packet=16M
```

Related messages:

| Message                                                                                    | Meaning                                                               |
| ------------------------------------------------------------------------------------------ | --------------------------------------------------------------------- |
| A picture is too large to store. Use a smaller or simpler picture.                         | One picture could not be made small enough for one database row       |
| The design is too large. Use fewer or smaller pictures.                                    | The layers of the design are over 4 MB                                |
| The database did not save that. Try again in a moment. The server console has the details. | Another database error. Look for `query failed` in the server console |

## The studio does not open or does not answer

| Message                                                        | Meaning                                                 | What to do                                                                                                           |
| -------------------------------------------------------------- | ------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| You may not open the Weapon Studio.                            | No permission                                           | Add the ACE `cas.weaponstudio`, or put the player's group in `Config.AdminGroups`. On standalone only the ACE works  |
| The studio is still starting. Try again in a moment.           | The database is not ready yet                           | Wait. The first connection can take some seconds                                                                     |
| Something went wrong on the server.                            | The studio could not start, or a request failed         | Read the server console. `could not start:` means the database was not reached: start `oxmysql` before this resource |
| The server did not answer. Try again.                          | No answer within 30 seconds                             | Check that the resource folder is named `cas-weaponstudio` and that the resource is started                          |
| The weapon library is missing (html/targets). Rebuild the NUI. | Files of the resource are missing                       | Install the resource again                                                                                           |
| The server does not know that request. Update the script.      | The client and server files are from different versions | Install the whole resource again                                                                                     |

## The skin book

| What you see                                       | Why                                                                                                                                                                                       |
| -------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| "Skins are sold at gunsmiths."                     | The book was opened away from a gunsmith with `Config.ApplyAnywhere = false`                                                                                                              |
| The book opens but "For sale here" is empty        | The player is not within `Config.TownRange` of a gunsmith, or no live skin is handed out to this town                                                                                     |
| A skin is sold in the wrong town, or in none       | Open its hand-out in the Saved tab and check the towns. If you changed a town's `id` in `Config.Towns`, pick the town again                                                               |
| No camera, the book is in the middle of the screen | The showcase needs a weapon of the studio in the hand, on foot. Take the weapon out before opening the book                                                                               |
| "Take your in your hand to try it"                 | A skin can only be tried on the weapon it is made for                                                                                                                                     |
| A player's skin is gone                            | The design was deleted, a gift was taken back, or the player left the job the skin was free for                                                                                           |
| Another player does not see the skin               | They must be within `Config.DrawDistance`, and at most `Config.MaxSkinnedWeapons` skinned weapons show on one screen. Seeing another player's skin is code only, not verified in game yet |

## Custom guns

| What you see                                                             | Why                                                                                                            |
| ------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------- |
| The Custom tab is missing                                                | `Config.Editions.enabled` is `false`                                                                           |
| The gun is not in the book                                               | It is off sale, no town is picked for it, or the player is at another town's gunsmith                          |
| The gun arrived without its skin                                         | The skin was not live when the gun was bought. After the restart the skin is under "My skins": put it on there |
| "You cannot carry another weapon of that kind."                          | VORP: the inventory refused another weapon. Nothing was paid                                                   |
| "The gunsmith could not hand the weapon over. You have your money back." | The framework did not give the weapon. The player was refunded                                                 |

## Export messages

| Message                                                                                         | What to do                                                                  |
| ----------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| The upload broke off. Try the export again.                                                     | Export again and keep the window open. An upload is dropped after 5 minutes |
| That slot is in use by the game right now. Export again after the restart.                      | Wait for the restart, then export again                                     |
| The texture had the wrong size.                                                                 | Export again. If it stays, install the resource again                       |
| The texture encoder did not load (html/bc.js). Rebuild the NUI.                                 | Files of the resource are missing. 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            |
| A built design keeps its weapon. Start a new design instead.                                    | An exported design cannot move to another weapon                            |

## Still stuck

Set `Config.Debug = true` on a test server, repeat the step and read the server console and the client console (F8). Lines from this script start with `[cas-weaponstudio]`.
