Skip to content

Commit 812fb21

Browse files
committed
Docs
1 parent 0d1f654 commit 812fb21

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3521
-1668
lines changed

documentation/docs/definitions/class.md

Lines changed: 61 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,36 @@ The global `CLASS` table defines per-class settings such as display name, lore,
1818
| `desc` | `string` | `"No Description"` | Description or lore of the class. |
1919
| `isDefault` | `boolean` | `false` | Whether the class is available by default. |
2020
| `isWhitelisted` | `boolean` | `false` | Whether the class requires whitelist to join. |
21-
| `faction` | `number` | `0` | Linked faction index (e.g., `FACTION_CITIZEN`). |
22-
| `color` | `Color` | `Color(255,255,255)` | UI color associated with the class. |
23-
| `weapons` | `table` | `{}` | Weapons granted to members of this class. |
21+
| `faction` | `number` | `required` | Linked faction index (e.g., `FACTION_CITIZEN`). |
22+
| `color` | `Color` | `nil` | UI color associated with the class; falls back to faction color when unset. |
23+
| `weapons` | `string` or `table` | `nil` | Weapons granted to members of this class. |
2424
| `pay` | `number` | `0` | Payment amount per interval. |
2525
| `payLimit` | `number` | `0` | Maximum accumulated pay. |
2626
| `payTimer` | `number` | `3600` | Seconds between paychecks when not overridden. |
2727
| `limit` | `number` | `0` | Maximum number of players in this class. |
28-
| `health` | `number` | `0` | Default starting health. |
29-
| `armor` | `number` | `0` | Default starting armor. |
28+
| `health` | `number` | `nil` | Starting health override. |
29+
| `armor` | `number` | `nil` | Starting armor override. |
3030
| `scale` | `number` | `1` | Player model scale multiplier. |
31-
| `runSpeed` | `number` | `0` | Default running speed. |
31+
| `runSpeed` | `number` | `nil` | Running speed or multiplier value. |
3232
| `runSpeedMultiplier` | `boolean` | `false` | Multiply base speed instead of replacing it. |
33-
| `walkSpeed` | `number` | `0` | Default walking speed. |
33+
| `walkSpeed` | `number` | `nil` | Walking speed or multiplier value. |
3434
| `walkSpeedMultiplier` | `boolean` | `false` | Multiply base walk speed instead of replacing it. |
35-
| `jumpPower` | `number` | `0` | Default jump power. |
35+
| `jumpPower` | `number` | `nil` | Jump power or multiplier value. |
3636
| `jumpPowerMultiplier` | `boolean` | `false` | Multiply base jump power instead of replacing it. |
3737
| `bloodcolor` | `number` | `0` | Blood color enumeration constant. |
38-
| `bodyGroups` | `table` | `{}` | Bodygroup name → index mapping applied on spawn. |
39-
| `logo` | `string` | `""` | Material path for the class logo. |
38+
| `bodyGroups` | `table` | `nil` | Bodygroup name → index mapping applied on spawn. |
39+
| `logo` | `string` | `nil` | Material path for the class logo. |
4040
| `scoreboardHidden` | `boolean` | `false` | Hide class headers and logos in the scoreboard. |
4141
| `skin` | `number` | `0` | Player model skin index. |
42-
| `subMaterials` | `table` | `{}` | Sub-material overrides for the model. |
43-
| `model` | `string` | `""` | Model path or list of paths used by this class. |
44-
| `requirements` | `string` | `""` | Informational requirements text shown to players. |
42+
| `subMaterials` | `table` | `nil` | Sub-material overrides for the model. |
43+
| `model` | `string` or `table` | `nil` | Model path or list of paths used by this class. |
44+
| `requirements` | `string` or `table` | `nil` | Informational requirements text shown to players. |
4545
| `index` | `number` | `auto` | Unique team index assigned at registration. |
4646
| `uniqueID` | `string` | `filename` | Optional identifier; defaults to the file name when omitted. |
47-
| `commands` | `table` | `{}` | Command names members may always use. |
47+
| `commands` | `table` | `nil` | Command names members may always use. |
4848
| `canInviteToFaction` | `boolean` | `false` | Allows members of this class to invite players to their faction. |
4949
| `canInviteToClass` | `boolean` | `false` | Allows members of this class to invite others to their class. |
50+
| `OnCanBe(client)` | `function` | `function(self, client) return true end` | Custom join check; return `false` to deny the client. |
5051

5152
---
5253

@@ -172,7 +173,7 @@ CLASS.isWhitelisted = false
172173

173174
**Description:**
174175

175-
Links this class to a specific faction index.
176+
Links this class to a specific faction index. This field is required; registration fails if the faction is missing or invalid.
176177

177178
**Example Usage:**
178179

@@ -190,7 +191,7 @@ CLASS.faction = FACTION_CITIZEN
190191

191192
**Description:**
192193

193-
UI color representing the class. Defaults to `Color(255, 255, 255)` if not specified.
194+
UI color representing the class. When omitted, the faction’s color is used.
194195

195196
**Example Usage:**
196197

@@ -206,16 +207,19 @@ CLASS.color = Color(255, 0, 0)
206207

207208
**Type:**
208209

209-
`table`
210+
`string` or `table`
210211

211212
**Description:**
212213

213-
Weapons granted to members of this class on spawn.
214+
Weapons granted to members of this class on spawn. Supply a single weapon class or a table of weapon class strings.
214215

215216
**Example Usage:**
216217

217218
```lua
219+
-- give two weapons
218220
CLASS.weapons = {"weapon_pistol", "weapon_crowbar"}
221+
-- or grant one weapon
222+
CLASS.weapons = "weapon_pistol"
219223
```
220224

221225
#### `pay`
@@ -304,7 +308,7 @@ CLASS.limit = 10
304308

305309
**Description:**
306310

307-
Default starting health for class members.
311+
Overrides the player’s starting health when they spawn as this class. If omitted, health is unchanged.
308312

309313
**Example Usage:**
310314

@@ -322,7 +326,7 @@ CLASS.health = 150
322326

323327
**Description:**
324328

325-
Default starting armor.
329+
Overrides the player’s starting armor. If omitted, armor remains unchanged.
326330

327331
**Example Usage:**
328332

@@ -358,9 +362,7 @@ CLASS.scale = 1.2
358362

359363
**Description:**
360364

361-
Default running speed. Set a number to override or a multiplier in
362-
363-
conjunction with `runSpeedMultiplier`.
365+
Overrides or multiplies the player's running speed. Set a number to replace the speed or a multiplier when used with `runSpeedMultiplier`. If unset, the run speed is unchanged.
364366

365367
**Example Usage:**
366368

@@ -401,7 +403,7 @@ CLASS.runSpeedMultiplier = true
401403

402404
**Description:**
403405

404-
Default walking speed.
406+
Overrides or multiplies the player's walking speed. If unset, the walk speed is unchanged.
405407

406408
**Example Usage:**
407409

@@ -437,7 +439,7 @@ CLASS.walkSpeedMultiplier = false
437439

438440
**Description:**
439441

440-
Default jump power.
442+
Overrides or multiplies the player's jump power. If unset, the jump power is unchanged.
441443

442444
**Example Usage:**
443445

@@ -493,7 +495,7 @@ CLASS.bloodcolor = BLOOD_COLOR_RED
493495

494496
**Description:**
495497

496-
Mapping of bodygroup names to index values applied when the player spawns.
498+
Mapping of bodygroup names to index values applied when the player spawns. If omitted, bodygroups are not modified.
497499

498500
**Example Usage:**
499501

@@ -514,7 +516,7 @@ CLASS.bodyGroups = {
514516

515517
**Description:**
516518

517-
Path to the material used as this class's logo. Displayed in the scoreboard and F1 menu.
519+
Path to the material used as this class's logo. When `nil`, no logo is displayed in the scoreboard or F1 menu.
518520

519521
**Example Usage:**
520522

@@ -568,7 +570,7 @@ CLASS.skin = 2
568570

569571
**Description:**
570572

571-
List of material paths that replace the model's sub-materials. The first entry applies to sub-material `0`, the second to `1`, and so on.
573+
List of material paths that replace the model's sub-materials. The first entry applies to sub-material `0`, the second to `1`, and so on. Leave `nil` for no overrides.
572574

573575
**Example Usage:**
574576

@@ -589,7 +591,7 @@ CLASS.subMaterials = {
589591

590592
**Description:**
591593

592-
Model path (or list of paths) assigned to this class.
594+
Model path (or list of paths) assigned to this class. When omitted, the character's existing model is used.
593595

594596
**Example Usage:**
595597

@@ -603,16 +605,19 @@ CLASS.model = "models/player/alyx.mdl"
603605

604606
**Type:**
605607

606-
`string`
608+
`string` or `table`
607609

608610
**Description:**
609611

610-
Text displayed to the player describing what is needed to join this class. This field does not restrict access on its own.
612+
Text displayed to the player describing what is needed to join this class. Accepts a string or list of strings. This field does not restrict access on its own.
611613

612614
**Example Usage:**
613615

614616
```lua
615-
CLASS.requirements = "Flag V and Engineering 25+"
617+
-- single requirement string
618+
CLASS.requirements = "Flag V"
619+
-- or list multiple requirements
620+
CLASS.requirements = {"Flag V", "Engineering 25+"}
616621
```
617622

618623
---
@@ -627,7 +632,7 @@ CLASS.requirements = "Flag V and Engineering 25+"
627632

628633
Table of command names that members of this class may always use,
629634

630-
overriding standard command permissions.
635+
overriding standard command permissions. If omitted, no extra commands are granted.
631636

632637
**Example Usage:**
633638

@@ -673,6 +678,26 @@ CLASS.canInviteToClass = true
673678

674679
---
675680

681+
#### `OnCanBe(client)`
682+
683+
**Type:**
684+
685+
`function`
686+
687+
**Description:**
688+
689+
Optional callback executed when a player attempts to join the class. `self` is the class table. Return `false` to block the player from joining.
690+
691+
**Example Usage:**
692+
693+
```lua
694+
function CLASS:OnCanBe(client)
695+
return client:IsAdmin()
696+
end
697+
```
698+
699+
---
700+
676701
## Complete Example
677702

678703
```lua
@@ -721,4 +746,7 @@ CLASS.commands = {
721746
}
722747
CLASS.canInviteToFaction = true
723748
CLASS.canInviteToClass = true
749+
function CLASS:OnCanBe(client)
750+
return client:IsAdmin()
751+
end
724752
```

0 commit comments

Comments
 (0)