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

# vorp\_character patch

Sell and wear CAS Clothing Studio designs in vorp\_character's clothing store and outfits on a RedM VORP server: install, manual edits, testing and uninstall.

A small patch for VORP's `vorp_character` so players can see, try on, buy, wear and save CAS Clothing Studio designs in vorp\_character's own clothing store and outfits.

{% hint style="warning" %}
Not tested in game yet: test it on a test server first. The patched code has only been run in a code test (a fake game and a fake server). Try every step in "Test it" below on a test server before you put it on a live one.
{% endhint %}

Target: [vorp\_character-lua](https://github.com/VORPCORE/vorp_character-lua) at commit `8569e37` (2026-05-01). Other versions may need the manual edits below.

## What it does

* **Clothing store.** In each garment category the Studio has designs for (vests, shirts, coats, closed coats, pants, skirts, ponchos, cloaks) the store gets one more row, **Designs**. It lists the designs this character owns and the designs sold in this store's town, with the price or "(Owned)". Moving the row puts the design on the character to look at. "None" keeps the garment on, plain.
* **Buying.** The store's total shows vorp\_character's own price for the other pieces plus the price of each new design the character does not own yet. When the player buys, the server first keeps only the design ids that sit on their own garment (the Studio says which garment each design is); any other id goes and that slot costs vorp\_character's own price as the plain garment. Then the Studio quotes the new designs at this store (an owned design is free). If it refuses one (not sold in this town, no designs at this store), or the player's money does not cover vorp\_character's part plus the designs, the player is told why and nothing is charged or saved. Otherwise the designs are bought through the Studio (it charges its own price), then vorp\_character charges its own part and saves the clothes. Switching to a design the character already owns counts as a change, so Buy works even when the total is 0.
* **Wearing.** The character's clothes keep only the design's id, on that garment (`compTints[Category]["<garment hash>"].design = <id>`). Every time vorp\_character dresses the character (spawn, `/rc`, death, store exit, outfit, the toggle commands such as `/vest` and `/dress`) the Studio puts the design's texture on that garment again. A design id never moves to another garment.
* **Outfits.** An outfit saved at the store keeps its designs. Wearing an outfit shows a design only if the character owns it (or its job may wear it); otherwise the plain garment shows.
* **The Studio stays in charge.** Which designs a character may wear, the price in each town and the texture all come from cas-clothingstudio. After every save of clothes vorp\_character tells the Studio what is worn now, so other players see the same designs.
* **Without the Studio** (cas-clothingstudio stopped or not installed) the hooks never call it and vorp\_character works as stock. Design ids already saved stay in the data, so they come back when the Studio runs again. A design picked just before the Studio stopped is dropped at the purchase (nobody can sell it) and its garment costs vorp\_character's own price: no design id makes a garment free.

## Install

1. Make a backup of your `vorp_character` folder.
2. Copy `cas_designs.lua` and `cas_designs_server.lua` from `integrations/vorp_character/` in your download into your `vorp_character` folder, next to its `fxmanifest.lua`.
3. Apply the patch. Open a terminal in your `vorp_character` folder and run:

   ```
   git apply --check path/to/vorp_character.patch
   git apply path/to/vorp_character.patch
   ```

   The first line only checks; the second one changes the files. The patch also adds the two files to `fxmanifest.lua`. You need [Git](https://git-scm.com/) for this, but the folder does not have to be a git repository.

   If it says "patch does not apply" and your files have Windows line endings, try `git apply --ignore-whitespace path/to/vorp_character.patch`. If it still does not apply (another vorp\_character version, or your own changes), make the manual edits below instead.
4. Make sure `cas-clothingstudio` is started in your server config (before or after vorp\_character, either works).
5. Restart the server. The console shows `[cas-clothingstudio] clothing script integrated: vorp_character`. With `Config.UseTailors = "auto"` (the Studio's default) the Studio's own tailor counters then turn off, because players buy and wear designs in the clothing store.

## The manual edits

If you do not use `git apply`, make these edits by hand. Each one adds a line (or changes one) and calls the two helper files. Copy the lines exactly, comments included.

### fxmanifest.lua

In `client_scripts`, before `'client/*.lua',` add:

```lua
'cas_designs.lua', -- CAS Clothing Studio designs (client)
```

In `server_scripts`, before `'server/*.lua',` add:

```lua
'cas_designs_server.lua', -- CAS Clothing Studio designs (server)
```

### server/server.lua

1. `ConvertTable`: after `NewComps[k].palette = compTint.palette or 0` add:

   ```lua
   NewComps[k].design = tonumber(compTint.design) -- CAS Clothing Studio: the design on this garment (data only)
   ```
2. `RegisterNetEvent("vorpcharacter:setPlayerCompChange", ...)`: after `character.updateComps(json.encode(compsValues))` add:

   ```lua
   CASDesignsServer.Sync(_source, compsValues) -- CAS Clothing Studio (cas_designs_server.lua)
   ```
3. `Core.Callback.Register("vorp_character:callback:PayToShop", ...)`: as the first line inside the function, before `local user = Core.getUser(source)`, add:

   ```lua
   if not CASDesignsServer.Buy(source, arguments) then return callback(false) end -- CAS Clothing Studio: new designs first
   ```
4. The same `PayToShop` callback: after the `if arguments.compTints then ... end` block add:

   ```lua
   CASDesignsServer.Sync(source, arguments.comps, arguments.compTints) -- CAS Clothing Studio (cas_designs_server.lua)
   ```
5. `Core.Callback.Register("vorp_character:callback:PayForSecondChance", ...)`: after the `if data.compTints then ... end` block add:

   ```lua
   CASDesignsServer.Sync(source, data.comps, data.compTints) -- CAS Clothing Studio (cas_designs_server.lua)
   ```
6. `Core.Callback.Register("vorp_character:callback:SetOutfit", ...)`: after `character.updateCompTints(arguments.Outfit.compTints or '{}')` add:

   ```lua
   CASDesignsServer.Sync(source, arguments.Outfit.comps or '{}', arguments.Outfit.compTints or '{}') -- CAS Clothing Studio
   ```

### client/client.lua

`local function ApplyAllComponents(category, value, ped, set)`: as the last line of the function, after the `if value.palette ~= 0 then ... end` block and before the function's final `end`, add:

```lua
CASDesigns.Apply(ped, category, value, set) -- CAS Clothing Studio: the design on this garment (cas_designs.lua)
```

### client/creator\_functions.lua

1. `ConvertTableComps`: after `NewComps[k].palette = compTint.palette or 0` add:

   ```lua
   NewComps[k].design = tonumber(compTint.design) -- CAS Clothing Studio (data only)
   ```
2. `SetCachedClothingIndex`: after the line `PlayerTrackingData[key][value.comp] = { index = indexCategory, color = indexComp, ... }` add:

   ```lua
   PlayerTrackingData[key][value.comp].design = value.design -- CAS Clothing Studio (data only)
   ```
3. The same function: right before `if key == "Teeth" then` add:

   ```lua
   CASDesigns.Track(key, value) -- CAS Clothing Studio: a design garment the store's list does not have
   ```

### client/functions.lua

1. `UpdateCache`: in both `CachedComponents[key] = { ... }` tables, after the `palette = ...,` line, add:

   ```lua
   design = CASDesigns.Carry(value, CachedComponents[key]), -- CAS Clothing Studio (data only)
   ```
2. `AssertCachedComponents`: change `color = v.color` to `color = v.color,` and add after it:

   ```lua
   color = v.color,
   design = v.design -- CAS Clothing Studio (data only)
   ```

### client/menu.lua

1. `local function ReloadAllComponents()`: as the last line of the function, before its final `end`, add:

   ```lua
   CASDesigns.StoreRestamp() -- CAS Clothing Studio: the store's design slots stamped again (cas_designs.lua)
   ```
2. `OpenClothingMenu`, where the store handles `"buy"`: change `if GetCurrentAmmountToPay() > 0 then` to:

   ```lua
   if GetCurrentAmmountToPay() > 0 or CASDesigns.Changed() then -- CAS Clothing Studio: a design change counts
   ```
3. `OpenComponentMenu`: right before `MenuData.Open('default', GetCurrentResourceName(), 'OpenComponentMenu',` add:

   ```lua
   CASDesigns.StoreElement(elements, category) -- CAS Clothing Studio: the Designs row (cas_designs.lua)
   ```
4. `OpenComponentMenu`, in the menu's function: after the `if (data.current == "backup") then ... end` block add:

   ```lua
   if CASDesigns.StoreSubmit(data, menu, category, Applycomponents, TotalAmountToPay) then return end -- CAS Clothing Studio
   ```

### client/createCharacter.lua

`StartPrompts`: change `TotalToPay = T.Other.total .. GetCurrentAmmountToPay() .. "~q~ "` to:

```lua
TotalToPay = T.Other.total .. (GetCurrentAmmountToPay() + CASDesigns.Bill()) .. "~q~ " -- CAS Clothing Studio: + designs
```

### client/commands.lua

1. `local function toggleComp(hash, item, key)`: after `SetResourceKvp(tostring(item.comp):format(CHARID or 0), "false")` add:

   ```lua
   CASDesigns.Apply(PlayerPedId(), key, item) -- CAS Clothing Studio: the design on this garment (cas_designs.lua)
   ```
2. `RegisterCommand("dress", ...)`: as the last line of the command's function, before `end, false)`, add:

   ```lua
   CASDesigns.ApplyAll(PlayerPedId(), CachedComponents, true) -- CAS Clothing Studio: the designs on these garments
   ```

## Good to know

* **Towns.** A store sells the designs of the town in the Studio's `Config.Towns` whose coords are nearest to where the player stands in the store, within `Config.TownRange` metres. vorp\_character's default stores are next to the default towns. A store farther away from every town sells no designs; its Designs row then shows only the designs the character owns. If you moved or added stores, add their towns to the Studio's `Config.Towns`.
* **Money.** vorp\_character charges its own part in cash, as before. The Studio charges each design with its own buy (through its framework bridge). Before anything is charged the server checks the whole bill: the Studio's quote for the new designs plus vorp\_character's part, against the player's money. A player who cannot pay all of it buys nothing. The Studio can still refuse a design at the moment it sells it (the money changed in between, the Studio got busy): designs bought before that in the same visit stay owned, the visit is cancelled and vorp\_character charges nothing; the player can wear those designs for free next time. If the Studio does not answer in time (it is starting or busy), the visit stops and nothing is charged.
* **Prices of plain garments.** vorp\_character's server takes the store total its client sends (stock behaviour). The patch only adds back vorp\_character's own price (`config_shops.lua`) for a slot whose design id was dropped.
* **Dye.** A design can't be dyed: the tint and palette rows do nothing while a design is on (they are greyed out with vorp\_menu 1.3 or newer).
* **Character select.** Designs do not show on the character select preview; they appear once the character spawns.
* **Store exit without buying** puts the old clothes back (vorp\_character's own `/rc`), with their designs.
* **Rolled sleeves and tucks** (`/sleeves`, `/sleeves2`, `/tuck`): the game swaps the piece and drops the texture; the Studio puts it back on its own pieces within a few seconds. Test these on your server.
* **Resource name.** The patch registers with the Studio under vorp\_character's own resource name, so a renamed folder still works.
* **Player data.** Only the design id is saved, inside the existing `compTints` column. Nothing else in your database changes.

## Test it

On a test server, with cas-clothingstudio running and at least one design sold in Blackwater and one owned:

1. Open the Blackwater clothing store, pick a category with designs, move the Designs row: the design shows on the character, the total grows by its price, the dye rows do nothing.
2. Leave without buying: the old clothes come back, no money is taken.
3. Buy: the money for the design and for the other pieces is taken once each; the design stays on after leaving.
4. Relog, die and respawn, `/rc`, `/vest` off and on, `/dress`: the design comes back each time.
5. Save the look as an outfit, wear another outfit, then the first one again.
6. A second character who does not own the design wears an outfit with it (or gets the same data): the plain garment shows.
7. Try to buy a design with too little money, also with enough for the other pieces but not for the design too: the player is told why, nothing is charged, nothing is saved.
8. Stop cas-clothingstudio: the store has no Designs row and works as stock; the design garments show plain.

## Uninstall

1. In your `vorp_character` folder run `git apply -R path/to/vorp_character.patch` (or undo the manual edits, or put your backup back).
2. Delete `cas_designs.lua` and `cas_designs_server.lua` from the folder.
3. Restart the server. Saved design ids stay in `compTints` as unused data; stock vorp\_character ignores them and shows the plain garments.

## Licence

These files are licensed like vorp\_character: the GNU General Public License, version 2 or (at your option) any later version. See `LICENSE` in `integrations/vorp_character/`. They ship as plain source, never escrowed. The cas-clothingstudio resource itself is a separate program with its own terms.
