How fptje/darkrp works
1. Project type and runtime
- This is a Garry’s Mod Lua gamemode: the core code runs inside the GMod client/server environment, not as a standalone app.
- The repo is structured around GMod’s standard split between server (init.lua), client (cl_init.lua), and **shared (shared.lua / sh_*.lua)** code.
2. Top-level architecture
- The repository is organized into three main areas:
- gamemode/: the actual DarkRP framework and feature modules.
- entities/: custom scripted entities and weapons exposed to players and the world.
- content/: assets such as materials, icons, and sounds used by the UI and gameplay.
- The README makes the boundary explicit: DarkRP is the core, and customization is intended to happen in a separate DarkRPMod, not by editing core files.
3. Core bootstrap and loading
- gamemode/init.lua and gamemode/cl_init.lua are the entry points.
- The core loader in gamemode/libraries/ plus the config files under gamemode/config/ initialize the framework, then load modules and expose interfaces.
- This repo relies heavily on modular loading rather than one monolithic gameplay file.
4. Module system as the main architectural unit
- Most gameplay features live under gamemode/modules/.
- Modules are split by responsibility and often by execution context:
- client UI/HUD: cl_*.lua
- server logic: sv_*.lua
- shared rules/interfaces: sh_*.lua
- This is the key boundary to show in a diagram: modules encapsulate feature areas and communicate via shared interfaces rather than direct cross-file coupling.
5. Gameplay subsystems
- The main gameplay subsystems are:
- jobs/ranks (modules/jobs, modules/police)
- money and economy (modules/money, modules/hungermod, modules/tipjar)
- doors and ownership (modules/doorsystem)
- chat, commands, and messaging (modules/chat, modules/hud, modules/darkrpmessages)
- admin and moderation (modules/fadmin, modules/logging, modules/events)
- player state and movement (modules/afk, modules/sleep, modules/playerscale, modules/deathpov, modules/fspectate)
- roleplay interactions and minifeatures (modules/f4menu, modules/f1menu, modules/hitmenu, modules/voting, modules/hobo, modules/medic)
- These are the primary functional blocks for an architecture diagram.
6. Entity and weapon layer
- entities/entities/ contains world entities such as money printers, drugs, doors-related props, billboards, tip jars, letters, and law boards.
- entities/weapons/ contains roleplay tools and weapons such as lockpick, keys, arrest stick, tool variants, and custom CS-style weapons.
- Many of these follow the same pattern: shared definition + server behavior + optional client UI, and they connect back into the module system for actions, commands, and permissions.
7. Client-facing UI surface
- The client side is concentrated in menus and HUD subsystems:
- HUD and chat (modules/hud, modules/chat, modules/chatindicator)
- F4/F1 menus for jobs, entities, chat commands, and help (modules/f4menu, modules/f1menu)
- admin UI / scoreboard / player controls (modules/fadmin)
- These UIs typically read shared state from the server through interfaces and render player-facing controls.
8. Server-side authority and persistence
- Server modules own the authoritative game state: money, ownership, job changes, door permissions, jail, voting, and admin actions.
- Persistent or semi-persistent data flows are handled in modules like base, positions, logging, fadmin, and the SQLite/MySQL support libraries.
- The repo includes gamemode/libraries/mysqlite/ and gamemode/config/_MySQL.lua, indicating optional database-backed persistence depending on server setup.
9. External integrations and compatibility
- The repo has explicit compatibility/integration code for other Garry’s Mod ecosystems:
- CPPI (modules/cppi) for prop protection interoperability.
- FPP (modules/fpp) for prop protection.
- Lua linting in CI via .github/workflows/run-glualint.yml and glualint.json.
- These are important boundaries because they affect how DarkRP interacts with the wider server ecosystem, especially ownership and build permissions.
10. Configuration and customization model
- Runtime behavior is driven by gamemode/config/ files for items like entities, ammo types, jobs, licenses, and general settings.
- The README strongly indicates the intended extension pattern:
- use DarkRPMod for customization,
- or use the derived gamemode if building a forked variant.
- For a diagram, treat config/ as the policy/data layer and modules/ as the implementation layer.
11. Content assets
- content/materials/ and content/sound/ provide the visual/audio assets used by HUDs, admin icons, entity icons, and effects.
- These are not logic-heavy, but they are part of the client presentation path and should be shown as a separate asset dependency from Lua code.
12. Operational and maintenance boundaries
- The repository includes .github/ workflows, issue templates, and helper docs, but these are supporting infrastructure rather than runtime architecture.
- Files named “DO NOT TOUCH” and the README guidance reinforce that the core DarkRP repo is meant to stay stable, while derived customization lives elsewhere.
Main entry points: base Base · fadmin FAdmin · entities Entities · init.lua init.lua
Components 22
Core gamemode
Bootstrap, configuration, libraries, and modular loaders.
- init.lua · Server entry point for the gamemode.
gamemode/init.lua - cl_init.lua · Client entry point for the gamemode.
gamemode/cl_init.lua - Config · Runtime settings, entity lists, job data, licenses, and database config.
gamemode/config - Libraries · Shared helpers, interface loading, and database utility support.
gamemode/libraries
Gameplay modules
Feature subsystems that implement DarkRP rules and player-facing behavior.
- Base · Core shared/server/client primitives used by most modules.
gamemode/modules/base - Jobs · Job definitions, commands, and job-related interfaces.
gamemode/modules/jobs - Money · Player cash, payment, and money-related commands/interfaces.
gamemode/modules/money - Doors · Door ownership, permissions, administration, and door variables.
gamemode/modules/doorsystem - Chat · Chat commands, listeners, and message handling.
gamemode/modules/chat - HUD · Player HUD and related client-facing display logic.
gamemode/modules/hud - F4 menu · Main in-game interaction menu for jobs and entities.
gamemode/modules/f4menu - FAdmin · Admin control panel, scoreboard, actions, and moderation tools.
gamemode/modules/fadmin - Hunger · Hunger system and food-related UI/commands.
gamemode/modules/hungermod - Police · Police-team commands and police-specific rules.
gamemode/modules/police - Positions · Spawn points, jail positions, and position persistence.
gamemode/modules/positions - Logging · Server-side event logging and admin traceability.
gamemode/modules/logging - Voting · Vote questions, vote handling, and vote-related chat commands.
gamemode/modules/voting
Entities and weapons
Scripted entities and tools exposed to players and the world.
Content
Materials and sounds used by UI and gameplay.
- Content · Materials and sounds for UI, icons, and effects.
content
Connections 23
- init.lua → Config: loads · Initializes configuration before systems are brought up.
- init.lua → Libraries: uses · Bootstraps shared loaders and helper libraries.
- init.lua → Base: starts · Brings up the core foundation layer.
- cl_init.lua → Base: reads · Client bootstrap depends on the shared foundation layer.
- Base → Jobs: exposes · Shared interfaces and helpers feed feature modules.
- Base → Money: exposes · Provides common primitives for economy logic.
- Base → Doors: exposes · Provides shared utilities and entity/state hooks.
- Base → Chat: exposes · Chat and command infrastructure build on core primitives.
- Base → HUD: feeds · Client HUD state is sourced from shared core data.
- Base → F4 menu: feeds · Menus read shared state and permissions from the base layer.
- Base → FAdmin: feeds · Admin UI and moderation tools depend on core interfaces.
- Base → Hunger: exposes · Survival rules hook into common player and item state.
- Jobs → Police: extends · Police behavior builds on the job system.
- Jobs → Voting: drives · Voting interacts with job/team changes.
- Money → Entities: powers · Money flows into printers, cheques, tip jars, and spawned cash.
- Doors → Entities: governs · Door ownership and permissions affect world entities and tools.
- FAdmin → Logging: reports · Admin actions are captured by the logging subsystem.
- Positions → FAdmin: supports · Spawn/jail placement supports moderation and server control.
- CPPI → FPP: interop · Prop protection compatibility layers connect to each other and external ecosystems.
- Content → FAdmin: skins · Icons and materials support admin UI presentation.
- Content → HUD: skins · Materials and sounds support HUD and chat presentation.
- Content → Entities: skins · Entity icons and visuals are backed by asset content.
- Entities → Weapons: complements · World entities and player tools form the interactive object layer.