Introduction to cLib

Getting Started Updated: Dec 10, 2025

Introduction to cLib

cLib is a comprehensive utility library designed to simplify Garry's Mod addon development. It provides a robust foundation for building professional addons.

Features

FeatureDescription
VGUI Components20+ styled, reusable UI elements
MySQL IntegrationEasy database connectivity with MySQLOO
NetworkingSimplified net messages with auto-compression
Asset ManagementCentralized colors, fonts, and materials
Debug ToolsLogging with file output
Animation SystemSmooth animations with 15+ easing functions
i18n SupportMulti-language support for addons

Version

Current version: 1.3

Requirements

  • Garry's Mod (latest stable)
  • MySQLOO 9.8 Beta (optional, for database features)

Quick Start

-- Wait for cLib to load.
hook.Add("cLib.OnLoaded", "MyAddon.Init", function()
    print("cLib is ready!")
    
    -- Register colors
    cLib.AddColor("MyAddon.Primary", Color(100, 150, 200))
    
    -- Create fonts (client-side)
    if CLIENT then
        cLib.CreateFont("MyAddon.Title", "Roboto", 0.03)
    end
    
    -- Register network strings (server-side)
    if SERVER then
        cLib.Net.SetPrefix("MyAddon.")
        cLib.Net.Register("SyncData")
    end
end)

File Naming Convention

cLib uses file prefixes to determine where code runs:

PrefixRuns OnExample
sh_Client & Serversh_config.lua
sv_Server Onlysv_database.lua
cl_Client Onlycl_menu.lua