# Raze Developer Guide # Welcome Raze is a FiveM roleplay server built from scratch in TypeScript and React. It uses no Qbox, ESX, ox_lib, oxmysql or other framework: we own the core, the database layer, the UI and the inventory. This guide is for developers joining the project. Read it once before your first change. **Private** This guide is private. Don't share it, the repos, or anything from them outside the team. ## Where to go next - [Tech stack and layout]: what the code is made of and where it lives - [Getting started]: set up and run, by hand or with an AI - [Ground rules]: the three rules every change must follow - [Resource map]: which resource owns what - [Using AI on Raze]: give your Claude or other AI the project rules --- # Tech stack and repo layout Everything is TypeScript on Node 22 (`node_version '22'` in each manifest), bundled with esbuild and run with Bun scripts (`bun install`, then `bun run setup`, `bun run dev`, `bun run check`: see [Getting started]). | Part | What we use | | --- | --- | | Scripts | TypeScript, esbuild, `@citizenfx/client` and `@citizenfx/server` types | | UI (NUI) | React 19 in one shared resource, `raze_ui` | | Database | MariaDB/MySQL through our own `raze_db` (mysql2 pool) | | Fonts | Unbounded Bold for headlines (`@fontsource/unbounded`), Archivo for everything else (`@fontsource-variable/archivo`), standing in for Acumin Pro | | Screenshots | Playwright (`bun run shot`) | The code lives in the private `Raze-Roleplay/raze-fivem` repo. Assets are in separate private repos: `raze-mlo` (map interiors), `raze-props`, `raze-vehicles`, `raze-clothing` and `raze-weapons`. | Path | What's there | | --- | --- | | `resources/raze_*` | One folder per resource: `fxmanifest.lua`, `src/client`, `src/server`, often `src/shared`, JSON config, `sql/`, and `web/` for NUI files | | `packages/shared` | `@raze/shared`: shared types, helpers and the ready system. Each resource's types live here (`inventory.ts`, `jobs.ts`, ...) | | `scripts/` | Setup, build, check, new-resource, screenshot and asset tools | | `server/server.cfg` | The `ensure` order. FXServer runs from the repo folder with `+exec server/server.cfg` | | `server/secrets.cfg` | Your license key, picture key and wallet key. Gitignored, made by `bun run setup` | | `resources/[raze-*]` | The asset repos, cloned in as bracketed folders (gitignored here) | | `artifact/` | Your FXServer artifacts (gitignored) | | `dist/` | Build output, committed so the server runs straight after a pull. GitHub rebuilds it on every push to main if it's out of date, and fails a pull request whose build is stale. Never edit it by hand | | `.github/workflows` | That build check | --- # Getting started Ask Moe for access to the GitHub repos, the test server and your picture key first. You need [Git](https://git-scm.com), [Bun](https://bun.sh) and a MySQL or MariaDB server running on your computer. The `raze-fivem` folder is the server folder: FXServer runs from it, and the asset repos go in its `resources/`. 1. Clone `raze-fivem` and run `bun install` in it. 2. Clone each asset repo into `raze-fivem/resources/` as a bracketed folder: `raze-vehicles` as `[raze-vehicles]`, and the same for `raze-props`, `raze-mlo`, `raze-clothing` and `raze-weapons`. Each holds its resource one level down (`[raze-vehicles]/raze_cars`), so a plain `git pull` keeps it up to date. ```sh git clone https://github.com/Raze-Roleplay/raze-vehicles "resources/[raze-vehicles]" ``` 3. Download the latest recommended FXServer artifacts ([Windows](https://runtime.fivem.net/artifacts/fivem/build_server_windows/master/), [Linux](https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/)) and unpack them into `raze-fivem/artifact` (it's gitignored). 4. Run `bun run setup`. It asks for your database login (and makes the database if it isn't there), your cfx.re license key and your picture key (see below), then writes `resources/raze_db/config.json`, `resources/raze_core/logging.json` and `server/secrets.cfg`. Skip anything you don't have yet and run it again later: it only fills in what's missing. 5. Start the server from the `raze-fivem` folder: `artifact\FXServer.exe +exec server/server.cfg` on Windows, `./artifact/run.sh +exec server/server.cfg` on Linux. 6. The resources come built, so that's it. Run `bun run dev` while you work on code (it rebuilds on save), and `bun run check` before you hand anything in. It type-checks every resource, the web UI and `@raze/shared`. After a pull, run `bun install` and `bun run setup` again if anything new came in; both are safe to repeat. Run your server from a separate folder of your own instead? Clone the asset repos into that folder's `resources/`, and link three things back to `raze-fivem` so a pull updates them: `resources/[raze]` to `raze-fivem/resources`, `server.cfg` to `raze-fivem/server/server.cfg` and `server/secrets.cfg` to `raze-fivem/server/secrets.cfg`. Then start it with `+exec server.cfg`. The AI route below can do this for you. | Command | What it does | | --- | --- | | `bun run setup` | Makes your local config and secrets files (run once) | | `bun run build` | Builds every resource into its `dist/` | | `bun run dev` | Same, in watch mode | | `bun run check` | Type-checks everything (must pass) | | `bun run new raze_` | Makes a new resource with the standard layout | | `bun run shot` | Takes UI screenshots with Playwright, for reviews | After a build, restart the resource in the server console (`ensure raze_`). Every resource must survive a restart while players are online (see [Ground rules]). ## Set it up with AI If you use Claude Code, Codex or another AI that can run commands, open it in the folder where you want the server and paste this in. It asks how you run your server first, then does everything except your keys: you type those into `bun run setup` yourself, so they never go into the chat. ```text Set up a local Raze FiveM dev server on this computer, following https://docs.razerp.net/guide/getting-started. 1. Ask me first: do I run the server from inside the raze-fivem folder (the standard way), or from a separate server folder of my own? If separate, ask for its path. Wait for my answer. 2. Check that git, bun and a MySQL or MariaDB server are installed and running. If one is missing, tell me how to install it for my OS and stop. 3. Clone https://github.com/Raze-Roleplay/raze-fivem (into the current folder, or next to my server folder) and run bun install in it. 4. Clone raze-vehicles, raze-props, raze-mlo, raze-clothing and raze-weapons from the same GitHub org into bracketed folders ([raze-vehicles], [raze-props], [raze-mlo], [raze-clothing], [raze-weapons]) inside the resources folder of wherever the server runs: raze-fivem/resources, or my server folder's resources. They are large, so let each clone finish. 5. Download the latest recommended FXServer artifacts for my OS from runtime.fivem.net/artifacts/fivem and unpack them into raze-fivem/artifact (or my server folder, if it has none yet). 6. Separate server folder only: in my server folder, link resources/[raze] to raze-fivem/resources, server.cfg to raze-fivem/server/server.cfg, and server/secrets.cfg to raze-fivem/server/secrets.cfg (on Windows, a junction for the folder and hard links for the files), so a git pull updates everything. Don't overwrite anything already there without asking. 7. Don't run bun run setup and don't ask me for passwords or keys. Tell me to run bun run setup myself in the raze-fivem folder, and wait until I say it's done. 8. Start the server with +exec server/server.cfg from the raze-fivem folder, or +exec server.cfg from my server folder. Watch the console until the resources finish starting, and tell me about any errors or warnings with how to fix them. Don't commit, push or change any tracked file in the repos. ``` ## Your picture key Clothing, tattoo, furniture and emote pictures aren't in any repo. They come from our picture server, `cdn.razerp.net`, which only answers a key your server signs. Every developer has their own key: **ask Moe for yours.** Put it in `server/secrets.cfg`: ```ini set raze_cdn_key "the key Moe gave you" ``` - Keep it `set`, never `setr`: `setr` sends it to every player who joins. - Never commit it, paste it in chat or share it. `secrets.cfg` is gitignored. - Without it, the server warns at start and pictures are off: stores show numbers, and the emote and furniture menus show icons. Everything else works. - Restart `raze_appearance` after you set it. `bun run shot` reads the same key from `secrets.cfg`, so screenshots show pictures too. --- # Ground rules Three rules come before everything else: the server decides, every resource survives a restart, and every script is cheap to run. A change that breaks any of them gets sent back. ## Security first - The server decides money, items, jobs, task state, prices, and positions where it can. The client only displays and asks. - Validate every net event and callback on the server: types, ranges, ownership, state, distance and cooldowns. Nothing the client triggers grants anything on its say-so. - Assume every player dumps everything their client downloads: `files{}` entries, client JS, NUI, state bags and events. Locations, spawn pools, loot tables, rates, prices, admin lists and other players' info stay in server-only config and code. - Send each client only what that player needs right now, and re-check every interaction on the server. - Take net events through `onClient` and `onRequest` from `@raze/shared/server/net`. They check the arguments, rate limit, and refuse players who aren't playing a character unless the options say `character: false` (character select, staff tools). The rule check refuses raw net listeners in server code. - Bad arguments are logged to raze_core's security log and count as strikes. Three within ten minutes ping staff on Discord (when the security webhook is set); nobody is kicked. Change it under `strikes` in raze_core's `config.json`. - Text players typed (chat, texts, names, notes) shows as text, never HTML: no `dangerouslySetInnerHTML`, `innerHTML`, `outerHTML` or `insertAdjacentHTML`. The rule check refuses them. - A server `ExecuteCommand` runs with the resource's ACEs, so one built from values checks each value against a strict pattern first (see `raze_admin/src/server/aces.ts`). The rule check flags every one that isn't a plain string. - Secrets in `.cfg` files use `set`, never `setr` (sent to every player) or `sets` (shown on the server list). The rule check refuses ones named like a key, secret, token, password or webhook. ## Restart-safe - No `dependency` or `dependencies` in `fxmanifest.lua` (asset-only resources like `raze_mlo` are the exception). Load order comes from the `ensure` order in `server/server.cfg`. - Providers call `announceReady()` from `@raze/shared/ready` once they've fully started. - Anything you register into another resource goes inside `whenReady('', fn)`, and `fn` must be safe to run twice. Never use `onResourceStart` plus `setTimeout`. - `:ready` belongs to the ready system, so never name a net event `ready`. `onClient` and `onServer` refuse it. A client asking the server for its state again (after a restart) sends `clientReady`. - Loops over players already online use `untilReady('raze_core').then(...)`. Per-second loops that call `raze_core` start with `if (!isReady('raze_core')) return;`. - A `raze_core` restart keeps players in their character, and `raze_jobs` keeps duty. Never clear per-player state on `onResourceStop('raze_core')`; use `raze_core:characterUnloaded`. - A resource restarting mid-task cleans up its own entities and state, never pays twice, and leaves nothing behind. ```ts import { announceReady, whenReady } from '@raze/shared/ready'; whenReady('raze_interact', () => { // register points here; this may run again after raze_interact restarts }); announceReady(); ``` ## Performance first Every script is built to be cheap: near 0.00 ms in `resmon` when idle, and no hitches on the server thread. Treat a cost you could have avoided as a bug. - Client `setTick` runs only while it's needed (the player is nearby, a screen is open) and is cleared afterwards. Anything that doesn't need every frame uses an interval or an event. - Proximity checks walk a short list of nearby points refreshed every second or so, never every point on the map each frame. - Send the least you can over the network: only to the players who need it, and only what changed. Nothing goes out every frame or as an every-second broadcast. Use state bags only for what other clients must see. - No database queries in loops or per-player timers. Cache read-mostly data in memory, write once per action, and index the columns you look things up by. - Release whatever you load and create: call `SetModelAsNoLongerNeeded` after spawning, delete entities, and clear ticks and timers when you're done and when the resource stops. - NUI renders only while it's open and never polls. - Measure before you hand work in: `resmon` on the client, and `razecost` (or the admin Performance page) on the server. ```ts // Draw only while someone is near: the tick starts and stops with distance. let tick: number | null = null; setInterval(() => { const near = isNearAny(); // checks a short nearby list, not the whole map if (near && tick === null) tick = setTick(draw); else if (!near && tick !== null) { clearTick(tick); tick = null; } }, 1000); ``` --- # Resource map There are 21 code resources plus 4 asset-only ones, listed in `ensure` order. New features go into the resource that already owns that area; we avoid lots of small resources. Small quality-of-life features go in `raze_smallresources`. | Resource | Owns | | --- | --- | | `raze_db` | MySQL pool and migrations for everyone (server only) | | `raze_core` | Login, characters, spawning, digital accounts, metadata, saving, logging (DB + Discord) | | `raze_ui` | The one React NUI: every screen, toasts, progress bars, the radial wheel | | `raze_voice` | Voice and radio | | `raze_chat` | Chat | | `raze_hud` | Status and vehicle HUD, round minimap (display only) | | `raze_interact` | Every world interaction: look at it, scroll, press E | | `raze_jobs` | Jobs, ranks, duty, paychecks, the taxi, trucking and garbage jobs | | `raze_business` | Government, public and player-run businesses, rank permissions | | `raze_banking` | Accounts, branches, ATMs, transfers, invoices | | `raze_appearance` | Character creator, clothing, barber and tattoo shops, outfits | | `raze_inventory` | Slots and weight, containers, stashes, shops, weapons, crafting bench | | `raze_props` / `raze_cars` / `raze_clothing` / `raze_mlo` / `raze_weapons` | Streamed assets only, from the asset repos | | `raze_vehicles` | Ownership, dealer, garages, impound, keys, fuel, damage, mechanic repair | | `raze_emote` | Emotes, walks, moods, partner emotes, props held in hand | | `raze_medical` | Death, respawn, injuries, the EMS job | | `raze_police` | Cuffs, escort, search, MDT and dispatch | | `raze_phone` | Phone and tablet apps, camera, photos, the Mober ride app | | `raze_housing` | Wiwang apartments, Sandy Shores trailers, furniture, doors | | `raze_smallresources` | Small quality-of-life features | | `raze_admin` | Staff menu, spawners, bans, warnings, logs | | `raze_dev` | Dev console commands. Test server only; never ensure it on live | Each resource's shared types are in `packages/shared/src/.ts`. Exports are typed there and registered with `provideExports`, so you can read a resource's API without opening its code. --- # Code and UI conventions Write code that looks like the code around it: same structure, same naming, about the same number of comments. ## Code - TypeScript everywhere, strict, and `bun run check` must pass. - Settings go in each resource's JSON config files, not convars. Server-only settings stay in files that are never listed in `files{}`. - Use `@raze/shared` helpers before writing your own: `db`, the ready system, `provideExports` / `resourceExports`, progress bars (`@raze/shared/server/bar`) and the animation presets. - Every world interaction goes through `raze_interact`. No third-eye targeting and no plain "Press E" text. - New resources come from `bun run new raze_`, and only when no existing resource fits. - Never rename a command players already use. - US spelling in code, comments and UI text. ## UI (Raze blue) - Every screen lives in `raze_ui` and uses the tokens in `resources/raze_ui/web/src/styles.css`. - Deep navy panels. - One primary action per screen: a bright blue gradient button. - Color only for meaning, through the `--success`, `--danger`, `--warning` and `--info` tokens. No other accent colors. Job screens like the MDT may use their job's color inside. The phone app icons are colored on purpose; leave them. - Type, through the `--font-display` and `--font` tokens: - **Unbounded Bold** for headlines and section titles. Every `h1` and `h2` gets it automatically. - **Archivo Semibold** for subheadings (`h3`), navigation and buttons. - **Archivo Regular** for paragraphs and general content. - Archivo stands in for the brand's Acumin Pro, a paid Adobe font. If we get licensed Acumin files, swap the font files, `--font`, the loadscreen's `style.css` and this site's theme. - The logo is custom geometric lettering, not a font. Until we have it as an image, the RAZE wordmark is set in Unbounded. - Never use `backdrop-filter` blur. FiveM renders it as black boxes, so use rgba backgrounds instead. --- # Clothing How clothing packs, saved outfits and the store pictures fit together. Clothing lives in the private `raze-clothing` repo (the `raze_clothing` resource); the store is in `raze_appearance` and `raze_ui`. ## Where things go | What | Where | | --- | --- | | Models and textures | `raze-clothing/raze_clothing/stream//_//` (`civ1`, `civ2`, `police`; `replace` holds textures that replace base-game ones) | | Shop metas | `raze-clothing/raze_clothing/data//`, each registered in `fxmanifest.lua` as `SHOP_PED_APPAREL_META_FILE` | | Picture indexes | `raze-clothing/raze_clothing/web/pictures.json` (our packs, Rockstar DLCs from 2024 on) and `web/vanilla.json` (older Rockstar clothing) | | Store pictures | The picture server, `https://cdn.razerp.net/clothing/` (never in a repo) | Clothing files never leave the private repos. Any change in `stream/` needs a full server restart, and players must reconnect to see it. Ask Moe for the restart. ## Pieces are saved as pack and number The game numbers drawables globally: vanilla first, then every streamed pack in load order. Adding or removing a pack shifts every number after it, so a saved global number would point at the wrong piece. So every saved piece also carries its pin, `{ collection, local }`: the pack's collection name (its `dlcName` for that ped) and the drawable's number inside that pack. The client reads both with the collection natives (`GetPedCollectionNameFromDrawable`, `GetPedCollectionLocalIndexFromDrawable`) and turns a pin back into today's global number (`GetPedDrawableGlobalIndexFromCollection`). The server checks pins against `pictures.json` before saving. - Never store or compare bare global numbers for streamed clothing. Use the pin. - A pack's drawables are numbered `000` up with no gaps, and that number is the local index. - A drawable's `_1` file (a jacket open or closed) is an alternate, not a drawable of its own. ## Store pictures One picture per drawable (its first texture). In the store, the variant slider changes the texture live on the ped. Pictures aren't in `raze_clothing`'s `files{}`, so players don't download them on join. The picture server only answers a request carrying a key (`?k=`) that raze_appearance signs for a player in a character, with `raze_cdn_key` from `secrets.cfg` (see [Getting started](/guide/getting-started#your-picture-key)). Each key names its character and is capped per day, so a key copied out of the game can't pull the whole catalog. A key lasts until the end of the next day (UTC), and the client gets a new one before it runs out. Without a key, the store shows numbers. Each index lists a picture name for each local drawable of each slot: - a name: the picture file - `null`: no picture (the store shows its number) - `false`: an empty model with nothing to wear. The store hides it. The server refuses to sell empty pieces from `pictures.json` (`isEmptyPiece` in `@raze/shared/appearance`). - `'none'`: the base game's one empty piece in a component slot (no mask, no bag, shirtless). The store shows it as a None tile. Empty legs, shoes and torsos make the body vanish, so they're always hidden. ## Adding a clothing pack 1. Put the pack in `raze-clothing/raze_clothing/stream//` and its metas in `data//`, and register the metas in `fxmanifest.lua`. Every `dlcName` must be new. 2. Ask Moe for its pictures. Moe renders them, puts them on the picture server and sends you the updated `pictures.json`. 3. Commit the pack, metas and index in `raze-clothing`, and ask Moe for the restart. Until its pictures are up, a new pack shows numbers in the store. --- # Status and where to help Most systems are built, but many haven't been tested in-game yet. The fastest way to help is testing in-game and fixing what breaks. | Area | Status | Notes | | --- | --- | --- | | Core, jobs, businesses, banking | Needs in-game test | Coordinates and balance need a pass | | Inventory, weapons, vehicles | In progress | Weapon rework going on in `raze_inventory` | | Police, MDT and dispatch | In progress | MDT is a tablet app | | EMS | Needs in-game test | Injuries, defib, stretcher | | Civilian jobs | Needs in-game test | Taxi, Mober, garbage and trucking (convoys, weigh stations) | | Housing | In progress | Wiwang apartments and the first Sandy Shores trailer done; south side and Mirror Park houses being built | | Crafting bench | In progress | Mechanic parts bench | | Gangs | Open for help | Own resource, not designed yet | Pick an area with Moe before you start, so two people never build the same thing. --- # Using AI on Raze You can point Claude or another AI at Raze. These files give it the project rules, so its code follows them from the first try. | If you use | Do this | | --- | --- | | Claude Code, Codex, Cursor or Copilot in the repo | Nothing. `AGENTS.md` at the repo root (and `CLAUDE.md`, which loads it) is read automatically | | Claude on claude.ai or the desktop app | Download the [Raze skill](/raze-fivem-skill.zip) and upload it under Settings, then Capabilities, then Skills | | Any other chat AI | Download [llms-full.txt](/llms-full.txt) (the whole guide in one file) and attach it to your chat | Setting up a server? [Getting started](/guide/getting-started#set-it-up-with-ai) has a prompt that has an AI do it for you (it leaves your keys to you). The rules your AI gets are the same ones you follow: [Ground rules] and [Code and UI conventions]. Review what it writes like any other change.