> For the complete documentation index, see [llms.txt](https://5scripts-1.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://5scripts-1.gitbook.io/docs/assets/5s_racing/editable.md).

# Editable

> **Note:** The files in the `client/editable/` and `server/editable/` folders are open (listed in `escrow_ignore`) and meant to be adapted to your server. Edit the framework, payment, admin, ELO and class logic here without touching the core.

***

## server/editable/functions.lua

Framework / payment hooks. Edit these to fit your setup.

* **isAdmin(source)**
  * Whether the player is a racing admin (verify/delete any track, force start/end any race).
* **getRacingBalance(source)**
  * Returns the player's available balance, respecting `ConfigShared.paymentMethod` (`money` / `bank` / `both`).
* **payRacingReward(source, amount)**
  * Pays winnings to the configured account.
* **chargeRacingPayment(source, amount)**
  * Charges an entry fee; returns `false` if the player can't afford it. For `"both"` it takes cash first, then tops up from bank.
* **getPlayerIdentifier(source)**
  * Resolves the identifier set by `ConfigServer.UsedIdentifier`.

***

## server/editable/permissions.lua

Open hooks for **who** may create tracks and races. They run server-side and are the authoritative gate - the tablet's create buttons go through the same callbacks, so blocking here blocks the UI flow too.

* **canPlayerCreateTrack(source)**
  * May this player open the creator / save a new track?
* **canPlayerCreateRace(source)**
  * May this player host a race?

Return `true` to allow, `false` to block. You may return a **second** value - a locale key for the message shown to the blocked player (defaults are used if omitted). Add your own keys to `locales/*.json` for custom wording. `source` is the player's server id, so you can gate on jobs, gangs, ACE perms, items, etc.

```lua
function canPlayerCreateTrack(source)
    -- Example: only mechanics may build tracks
    if exports['your_jobs']:getJob(source) ~= 'mechanic' then
        return false, 'track_create_no_permission'
    end
    return true
end
```

***

## server/editable/elo.lua

The ELO algorithm. Open so you can fully customise or replace the maths. For the everyday settings (`kFactor`, `topPercentage`, etc.) use `ConfigShared.elo` instead.

* **calculateRaceElo(players, routeLengthMeters)**
  * Works out the new rating for every racer after a race.
  * Pulls `K`, `topPercentage`, `referenceLength` and the min/max length multipliers from `ConfigShared.elo`.
  * `routeLengthMultiplier = routeLengthMeters / referenceLength`, clamped to `[minLengthMultiplier, maxLengthMultiplier]` so a very long track can't balloon the swing and a tiny one isn't pointless. Applied once per race so the zero-sum redistribution stays balanced.
  * Standard Elo expected-vs-actual score per player, scaled by `K` and the length multiplier, then redistributed: losers below the top cut feed a loss pool that the top finishers share by weight.
* **calculateTrackLength(checkpoints)**
  * Adds up the distance between consecutive checkpoints to get a track's total length (metres).

***

## client/editable/performanceClass.lua

Vehicle class scoring.

* **GetVehiclePerformanceClass(vehicle)**
  * Decides a car's class.
    1. If `ConfigShared.vehicleClasses` has an override for the model, use it.
    2. Native classes map directly: 8 → `MT` (motorcycles), 9 → `OF` (off-road), 12 → `VN` (vans), 13 → `BK` (bicycles). Other non-car classes fall back to `D`.
    3. For cars, a `performanceScore` is computed from max speed, acceleration, handling (traction curve) and braking, then bucketed into `D / C / B / A / S / S+ / X` by thresholds. Tune the weights/thresholds here to rebalance the tiers.

***

## client/editable/utils.lua

* **createCheckpointBlip(checkpoint, blipColor)**
  * Creates the minimap blip for a checkpoint (sprite, scale, colour, short-range, numbered by checkpoint index). Edit to restyle blips.

***

> All files in the `editable` folders are intended for easy customization without affecting the core logic. For further customization, refer to the comments and structure in each file.
