How to Clone CityRP
Welcome to the CityRP development setup guide! This document will help you set up a local development environment for CityRP using a dedicated server setup.
Prerequisites
Before you start, make sure you have:
- Access to the gamemode repository: https://github.com/FearlessGaming/CityRP
- Access to the addons repository: https://github.com/FearlessGaming/FearlessAddons
- A MySQL database (recommended) or SQLite fallback
- Visual Studio Code with LuaLS extension (recommended for development)
Dedicated Server Setup
Note: The x64 branch is no longer supported. Use the default or "dev" 32-bit branch for your dedicated server.
Setting up a dedicated server provides a more accurate development environment compared to listen servers. While it requires more initial setup, this is a one-time effort that results in a significantly better development experience.
The Garry's Mod wiki has a comprehensive guide on setting up a dedicated server: https://wiki.facepunch.com/gmod/Downloading_a_Dedicated_Server
You should use this workshop collection on the server (same as production): https://steamcommunity.com/sharedfiles/filedetails/?id=2824995698
Note: If you have unique content required for your changes, you'll likely need to copy the collection above and add your own content (recommended) or manually add it (not recommended).
1. Repository Setup
You'll need to clone two repositories:
- CityRP Gamemode: https://github.com/FearlessGaming/CityRP
- CityRP Addons: https://github.com/FearlessGaming/FearlessAddons
Gamemode Repository
Clone the gamemode to .../garrysmod/gamemodes/cityrp/ in your dedicated server folder, ensuring that cityrp.txt is located at .../garrysmod/gamemodes/cityrp/cityrp.txt.
Important: Double-check the path! If the path is incorrect, the gamemode won't appear in the server.
If cloning creates a nested folder, you can clone elsewhere and move the contents (including the .git folder) to the correct location.
Addons Repository
Clone the addons repository into .../garrysmod/addons/, so that .gitattributes is located at .../garrysmod/addons/.gitattributes.
Similar to the gamemode, ensure the path is correct and move contents if necessary.
Custom Content
If your development requires new content, create your own workshop collection by copying the production collection and adding your custom items. This approach is more maintainable than manually adding content.
2. Install MySQLOO
Install MySQLOO for database connectivity. Download the appropriate version for your system (Windows/Linux, 32-bit/64-bit) and place the .dll files in .../garrysmod/lua/bin/. Create the bin folder if it doesn't exist.
Note: The migration system will automatically create all necessary database tables - no manual SQL imports required!
3. Optional Modules
Consider installing these optional modules for enhanced development experience:
- enginespew - Filters false errors and improves error formatting
4. Server Configuration
Create a server configuration file (sv_configuration.lua) using this template:
cityrpserver = cityrpserver or {} -- Database configuration - update with your credentials cityrpserver["MySQL Host"] = "host-here" cityrpserver["MySQL Username"] = "username-here" cityrpserver["MySQL Password"] = "password-here" cityrpserver["MySQL Port"] = 3306 -- Development optimizations cityrpserver["DisablePrecache"] = true -- Speeds up loading time -- Default database settings (usually don't need to change) cityrpserver["MySQL Database"] = "fearless_cityrp" cityrpserver["MySQL Table"] = "players" cityrpserver["MySQL Access Log Table"] = "accesslog" cityrpserver["MySQL Online Log Table"] = "onlinelog" cityrpserver["MySQL Log Table"] = "logs" cityrpserver["MySQL Chat Table"] = "chat" cityrpserver["MySQL RPP Table"] = "rppoints"
Copy this file to .../garrysmod/gamemodes/cityrp/gamemode/core/sv_configuration.lua. The file is git-ignored, so it won't cause conflicts.
Database Setup: The migration system will automatically create the database and tables. Contact a developer for shared development database credentials, or set up your own for better control.
5. Vehicle Scripts Setup
For vehicle-related development, you'll need to set up vehicle scripts. We recommend using a symlink for automatic updates.
Option 1: Symlink (Recommended)
A symlink automatically keeps your scripts synchronized with the repository.
Prerequisites:
- Delete existing .../garrysmod/scripts folder if it exists
- Note your gamemode scripts path: .../garrysmod/gamemodes/cityrp/scripts
Steps:
Open Command Prompt as Administrator
Navigate to your Garry's Mod directory:
Copy the path from Windows Explorer (
.../garrysmod/)In Command Prompt, type
cdfollowed by the pathVerify you're in the correct directory (path should appear before
>)Create the symlink:
```cmd mklink /J "scripts" "gamemodes/cityrp/scripts" ```
- Verify success - you should see:
```text Junction created for scripts <<===>> gamemodes/cityrp/scripts ```
Option 2: Manual Copy
If symlinks don't work, manually copy the contents of .../garrysmod/gamemodes/cityrp/scripts to .../garrysmod/scripts. Create the scripts folder if it doesn't exist.
6. Running the Server
Create a batch script to start your server. Save this as start_server.bat in your server directory:
srcds.exe +maxplayers 20 -console +gamemode cityrp -port 27015 +host_workshop_collection 2824995698 +map rp_evocity_v4b1_fl -tickrate 22 +sv_setsteamaccount <your_token>
Important Configuration:
- Replace
<your_token>with your GSLT token from Steam Game Server Accounts - The gamemode now supports Lua refresh, so
-disableluarefreshis no longer needed - Consider adding a password and other configuration options in
sv_configuration.lua
Starting the Server:
- Run the batch script
- Wait for the server to fully load
- Use
statuscommand in console to get the server IP - Connect via Garry's Mod client
7. Development Environment Setup
LuaLS for Visual Studio Code
For the best development experience, install LuaLS (Lua Language Server) in Visual Studio Code:
Install Visual Studio Code if you haven't already
Install the LuaLS extension:
Open VS Code
Go to Extensions (Ctrl+Shift+X)
Search for "LuaLS" or "sumneko.lua"
Install the extension by sumneko
Install Garry's Mod Plugin for LuaLS:
Open Command Palette (Ctrl+Shift+P)
Type "LuaLS: Open Plugin Manager"
Search for "Garry's Mod" plugin
Install the plugin
Configure for CityRP:
Open your CityRP workspace in VS Code
LuaLS will automatically detect Lua files and provide:
- Syntax highlighting - Error detection - Auto-completion - Type checking - Function signatures
The Garry's Mod plugin provides definitions for GMod-specific functions and globals, making development much more efficient.
Additional Development Tips
- Lua Refresh: The gamemode supports live Lua refresh - you can reload code without restarting the server
- Console Commands: Use
lua_runfor server-side testing andlua_run_clfor client-side testing - Debugging: Use
print()statements and the server console for debugging - Git Workflow: Create feature branches for development and submit pull requests for review