### Documentation Generation and Preview Source: https://github.com/parallax-framework/parallax/blob/main/README.md Installs necessary Python packages and generates documentation locally for preview. Ensure you have Python and pip installed. ```bash python -m pip install --upgrade pip pip install mkdocs-material python tools/generate_docs.py --clean mkdocs serve ``` -------------------------------- ### Font Naming Convention Examples Source: https://github.com/parallax-framework/parallax/blob/main/manuals/08-UI_THEME_GUIDELINES.md Examples demonstrating the font naming convention using size and style modifiers. ```lua "ax.regular" -- base font, no styles ``` ```lua "ax.regular.bold" -- bold weight ``` ```lua "ax.large.bold.italic" -- large bold italic ``` ```lua "ax.small.shadow" -- small with drop shadow ``` ```lua "ax.huge.bold.shadow" -- huge bold with shadow ``` -------------------------------- ### Example Parallax MySQL Configuration Source: https://github.com/parallax-framework/parallax/blob/main/manuals/intermediate/database_setup.md A realistic example of the database.yml file with sample credentials and a non-default port. Always use quotes for string values, especially passwords. ```yaml database: adapter: "mysqloo" hostname: "db.glnodes.com" username: "u47_ABC123xyz" password: "MySecureP@ssw0rd!2025" database: "s47_parallax" port: 50000 ``` -------------------------------- ### MODULE Table Initialization Example Source: https://github.com/parallax-framework/parallax/blob/main/manuals/01-ARCHITECTURE.md Shows how to define and initialize a module using the MODULE table. This includes setting the module's name and description, and defining an Initialize function. The example ensures the MODULE table exists before assigning properties and returns the MODULE table. ```lua -- modules/my_module/boot.lua MODULE = MODULE or {} MODULE.name = "My Module" MODULE.description = "A helpful module" function MODULE:Initialize() print("Module loaded:", MODULE.name) end return MODULE ``` -------------------------------- ### Item API: Get and Spawn Items Source: https://github.com/parallax-framework/parallax/blob/main/manuals/02-CORE_SYSTEMS.md Demonstrates how to retrieve item definitions by class, get item instances by ID, and spawn items into the game world. ```lua -- Get item definition by class local itemDef = ax.item:Get("pistol") -- Get item instance by ID local itemInstance = ax.item:Get(123) -- Spawn item in world (server) ax.item:Spawn("pistol", Vector(0, 0, 0), Angle(0, 0, 0), function(entity, itemObj) -- Callback when spawned end) ``` -------------------------------- ### ITEM Table Usage Example Source: https://github.com/parallax-framework/parallax/blob/main/manuals/01-ARCHITECTURE.md Demonstrates defining an item using the global ITEM table during file inclusion. This example sets the item's name, description, category, model, and weight. ```lua -- schema/items/sh_scrap_metal.lua ITEM.name = "Scrap Metal" ITEM.description = "A piece of scrap metal..." ITEM.category = "Junk" ITEM.model = Model("models/gibs/metal_gib4.mdl") ITEM.weight = 0.7 ``` -------------------------------- ### Item Methods: Get Weight and Check Usage Source: https://github.com/parallax-framework/parallax/blob/main/manuals/02-CORE_SYSTEMS.md Illustrates how to get an item's weight and check if a player can use it. ```lua -- Get item weight local weight = item:GetWeight() -- Check if player can use local canUse = item:CanUse(client) ``` -------------------------------- ### Get and Set Configuration Values Source: https://github.com/parallax-framework/parallax/blob/main/manuals/03-SCHEMA_DEVELOPMENT.md Retrieve configuration values using `ax.config:Get()` and set them using `ax.config:Set()`. A default value can be provided for `Get` to handle missing configurations gracefully. ```lua -- Get configuration value local serverName = ax.config:Get("server.name") local maxPlayers = ax.config:Get("server.max_players", 32) -- With default -- Set configuration ax.config:Set("server.name", "New Server Name") ``` -------------------------------- ### LDOC Documentation for Lua Function Source: https://github.com/parallax-framework/parallax/blob/main/manuals/intermediate/style.md Example of LDOC-compliant documentation for a shared function. Includes description, realm, parameters, and usage example. ```lua -- Sends a chat message to the player. -- @realm shared -- @param client Player The player receiving the message. -- @param ... any Message parts. -- @usage ax.util:SendChatText(client, "Hello", Color(255, 255, 255), " world!") function ax.util:SendChatText(client, ...) -- implementation end ``` -------------------------------- ### Vendor Callback Response Example Source: https://github.com/parallax-framework/parallax/blob/main/gamemode/modules/vendors/plan.md This is an example of a response object from a vendor that triggers a callback. It specifies the text to display, the action type, the callback function to execute, and any associated data. ```lua { text = "Any work available?", action = "callback", callback = "quest.offer", data = { questID = "delivery_01" } } ``` -------------------------------- ### ax.net:Start Source: https://github.com/parallax-framework/parallax/blob/main/manuals/05-API_REFERENCE.md Starts a network message, allowing messages to be sent to specified recipients or all clients. It supports sending data along with the message. ```APIDOC ## `ax.net:Start(recipients, message, ...)` ### Description Starts a network message (server). This function allows sending messages to specific players, a group of players, or all connected clients. Additional data can be passed along with the message. ### Method `Start` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - `recipients` (nil|Player|table|Vector) - Required - Recipients (nil = all) - `message` (string) - Required - Message name - `...` (any) - Optional - Message data ### Request Example ```lua -- Send to all clients ax.net:Start(nil, "my_message", data1, data2) -- Send to specific player ax.net:Start(client, "my_message", arg1, arg2) -- Send to multiple players ax.net:Start({client1, client2}, "my_message", arg1, arg2) ``` ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Inventory Entry Example Source: https://github.com/parallax-framework/parallax/blob/main/gamemode/modules/vendors/plan.md An example JSON object representing a single inventory entry for a vendor. This includes item identification, pricing, stock levels, and visibility settings. ```json { "itemID": "water", "buyPrice": 15, "sellPrice": 5, "enabled": true, "hidden": false, "stockEnabled": true, "stock": 20, "maxStock": 20, "restockAmount": 5, "restockInterval": 1800, "access": {}, "meta": {} } ``` -------------------------------- ### Start Network Message (Server) - ax.net Source: https://github.com/parallax-framework/parallax/blob/main/manuals/05-API_REFERENCE.md Use ax.net:Start to send network messages from the server. Specify recipients (nil for all, a player, a table of players, or a vector) and the message name, followed by any data arguments. ax.net:StartPVS is available for sending messages to players within a specific PVS. ```lua -- Send to all clients ax.net:Start(nil, "my_message", data1, data2) -- Send to specific player ax.net:Start(client, "my_message", arg1, arg2) -- Send to players in PVS ax.net:StartPVS(position, "my_message", arg1, arg2) -- Send to multiple players ax.net:Start({client1, client2}, "my_message", arg1, arg2) ``` -------------------------------- ### Creating a Regular Item Source: https://github.com/parallax-framework/parallax/blob/main/manuals/02-CORE_SYSTEMS.md Example of creating a regular item that can inherit from a base item or stand alone. ```APIDOC ## Creating a Regular Item ```lua -- schema/items/weapons/sh_pistol.lua ITEM.name = "9mm Pistol" ITEM.description = "A standard Combine-issued sidearm." ITEM.model = "models/weapons/w_pistol.mdl" ITEM.weight = 1.5 ITEM.category = "Weapons" ITEM.base = "weapon" -- Inherit from base -- Override base properties ITEM.description = "A reliable 9mm sidearm." -- Add custom action ITEM:AddAction("inspect", { name = "Inspect", icon = "icon16/magnifier.png", order = 2, CanUse = function(this, client) return true end, OnRun = function(action, item, client) client:Notify("This weapon is in good condition.") return false -- Don't consume the item end }) ``` ``` -------------------------------- ### Creating a Base Item Source: https://github.com/parallax-framework/parallax/blob/main/manuals/02-CORE_SYSTEMS.md Example of defining a base item, which serves as an abstract template for other items. ```APIDOC ## Creating a Base Item ```lua -- schema/items/base/sh_weapon.lua ITEM.name = "Weapon Base" ITEM.description = "A base weapon template" ITEM.model = "models/weapons/w_pistol.mdl" ITEM.weight = 2.0 ITEM.category = "Weapons" ITEM.isBase = true ITEM:AddAction("drop", { ... }) -- Common weapon functionality function ITEM:CanUse(client) return client:Alive() end function ITEM:OnDrop(client, position) -- Custom drop logic end ``` ``` -------------------------------- ### Lua Example Function with Indentation Source: https://github.com/parallax-framework/parallax/blob/main/manuals/intermediate/style.md Demonstrates proper indentation using 4 spaces for code blocks within a function. Avoid using tabs. ```lua function ax.util:ExampleFunction() local value = 10 if ( value > 5 ) then print("Value is greater than 5") end end ``` -------------------------------- ### Define an Item Source: https://github.com/parallax-framework/parallax/wiki/Creating-a-Schema Create a new item with properties like name, description, model, and weight. This is a basic example for item creation. ```lua ITEM.Name = "Example Item" ITEM.Description = "This is a test item." ITEM.Model = "models/props_junk/PopCan01a.mdl" ITEM.Weight = 1 ``` -------------------------------- ### Module Hook Example Source: https://github.com/parallax-framework/parallax/blob/main/manuals/02-CORE_SYSTEMS.md Modules can also define their own hooks. Ensure the module table is initialized if it doesn't exist. ```lua -- modules/my_module/sh_hooks.lua MODULE = MODULE or {} function MODULE:OnPlayerSpawn(player) -- Module-specific spawn logic end return MODULE ``` -------------------------------- ### Create and Restore Inventories in Parallax Source: https://github.com/parallax-framework/parallax/blob/main/manuals/backporting/helix/08-inventory.md Shows how to create persistent and temporary inventories in Parallax. Inventory restoration on server start is automatic. ```lua if ( SERVER ) then -- Create a new persistent inventory ax.inventory:Create({ maxWeight = 30 }, function(inventory) -- inventory is the new object with a database ID end) -- Or a temporary, non-persistent inventory (for containers that reset) local inv = ax.inventory:CreateTemporary({ maxWeight = 100 }) -- Restore on server start happens automatically — no explicit Restore call end ``` -------------------------------- ### Initialize a Module Source: https://github.com/parallax-framework/parallax/wiki/Creating-a-Schema Set up a custom module by defining its name, description, and an initialization function that runs when the module is loaded. ```lua MODULE.Name = "MyModule" MODULE.Description = "Test module." function MODULE:Initialized() ax.util:Print("Module loaded.") end ``` -------------------------------- ### Dialogue Structure Example in Lua Source: https://github.com/parallax-framework/parallax/blob/main/gamemode/modules/vendors/plan.md Defines the structure of a dialogue, including start node, and a list of nodes with text and responses. Responses can trigger actions like opening trade, moving to another node, or closing the interaction. ```lua dialogue = { start = "greeting", nodes = { greeting = { text = "What do you need?", responses = { { text = "Show me what you have.", action = "openTrade" }, { text = "Who are you?", next = "about" }, { text = "Never mind.", action = "close" } } }, about = { text = "I sell what people need. Sometimes more than that.", responses = { { text = "Let me see your stock.", action = "openTrade" }, { text = "Back.", next = "greeting" } } } } } ``` -------------------------------- ### Example: Hook Player Spawn Event Source: https://github.com/parallax-framework/parallax/wiki/Hooks Prints a message to the console when a player spawns. The 'client' argument contains information about the spawned player. ```lua hook.Add("PlayerSpawn", "PrintPlayerSpawn", function(client) print(client:Name() .. " has spawned.") end) ``` -------------------------------- ### Parallax Class Definition Example Source: https://github.com/parallax-framework/parallax/blob/main/manuals/backporting/helix/10-classes-and-attributes.md An example of a class definition in Parallax, demonstrating the equivalent of the Helix example with 'CanBecome' and centralized loadout logic. ```lua -- Parallax (`/gamemode/schema/classes/sh_tcp.lua`) CLASS.name = "Transhuman Arm" CLASS.description = "The elite of the Overwatch." CLASS.faction = FACTION_MPF CLASS.isDefault = false function CLASS:CanBecome(client) local char = client:GetCharacter() if ( !ax.character:GetVar(char, "data", "canBecomeTCP", false) ) then return false, "You are not authorized to join the Transhuman Arm." end return true end CLASS_TCP = CLASS.index ``` -------------------------------- ### Implement Module Hooks Source: https://github.com/parallax-framework/parallax/blob/main/manuals/02-CORE_SYSTEMS.md Defines functions that are called by the framework at specific events. This example shows hooks for schema loading and player spawning. ```lua -- modules/my_module/sh_hooks.lua MODULE = MODULE or {} function MODULE:OnSchemaLoaded() print("Schema loaded, module is active") end function MODULE:PlayerSpawn(client) print(client:Nick() .. " spawned") end return MODULE ``` -------------------------------- ### Inventory Structure Example Source: https://github.com/parallax-framework/parallax/blob/main/manuals/02-CORE_SYSTEMS.md Defines the typical structure of an inventory object, including its ID, items, maximum weight, and receivers. ```lua inventory = { id = 1, items = { [123] = itemInstance1, [124] = itemInstance2, }, maxWeight = 30.0, receivers = {player1, player2} } ``` -------------------------------- ### Server-Side Module Hook Example Source: https://github.com/parallax-framework/parallax/blob/main/manuals/intermediate/modules.md Implement server-side logic for a module hook, such as PlayerLoadout. Ensure the file is prefixed with 'sv_' for server-only execution. ```lua function MODULE:PlayerLoadout(client) -- module-specific loadout logic client:Give("weapon_pistol") end ``` -------------------------------- ### Framework Boot Sequence Source: https://github.com/parallax-framework/parallax/blob/main/manuals/01-ARCHITECTURE.md Defines the framework's metadata and loads core directories in a specific order: libraries, meta, core, hooks, networking, and interface. ```lua GM.Name = "Parallax" GM.Author = "riggs9162 & bloodycop6385" GM.Website = "https://discord.gg/yekEvSszW3" GM.Email = "riggs9162@gmx.de" -- Load directories in order ax.util:IncludeDirectory("libraries") -- Framework systems ax.util:IncludeDirectory("meta") -- Meta-tables ax.util:IncludeDirectory("core") -- Core functionality ax.util:IncludeDirectory("hooks") -- Framework hooks ax.util:IncludeDirectory("networking") -- Network handlers ax.util:IncludeDirectory("interface") -- UI systems ``` -------------------------------- ### Get Plugin: Helix vs Parallax Source: https://github.com/parallax-framework/parallax/blob/main/manuals/backporting/helix/01-namespace-map.md Retrieve a module by its ID using `ax.module:Get(id)` in Parallax. ```lua ix.plugin.Get(id) ``` ```lua ax.module:Get(id) ``` -------------------------------- ### Camera Configuration Example Source: https://github.com/parallax-framework/parallax/blob/main/gamemode/modules/vendors/plan.md Defines settings for a vendor's camera behavior during dialogue, including enabling the camera, transition durations, field of view, focus point, and collision tracing. ```lua camera = { enabled = true, duration = 0.35, returnDuration = 0.25, fov = 60, focusBone = "ValveBiped.Bip01_Head1", offset = Vector(0, 24, 8), maxDistance = 128, trace = true } ``` -------------------------------- ### Helix Plugin Hook Example Source: https://github.com/parallax-framework/parallax/blob/main/manuals/backporting/helix/07-hooks.md Example of a plugin hook method in Helix. This function will be dispatched when the 'PlayerSay' hook is called. ```lua function PLUGIN:PlayerSay(client, text) -- dispatched from HOOKS_CACHE["PlayerSay"] end ``` -------------------------------- ### Create MySQL Database and User via Command Line Source: https://github.com/parallax-framework/parallax/blob/main/manuals/intermediate/database_setup.md Use these SQL commands to create a new database, a user, and grant privileges. Ensure you replace 'your_password_here' with a strong password. ```sql CREATE DATABASE parallax_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'parallax_user'@'localhost' IDENTIFIED BY 'your_password_here'; GRANT ALL PRIVILEGES ON parallax_db.* TO 'parallax_user'@'localhost'; FLUSH PRIVILEGES; ``` -------------------------------- ### Get Configuration Values Source: https://github.com/parallax-framework/parallax/blob/main/manuals/04-ADVANCED_TOPICS.md Retrieve configuration values using `ax.config:Get`. A default value can be provided if the setting does not exist. ```lua -- Get configuration value local serverName = ax.config:Get("server.name") local maxPlayers = ax.config:Get("server.max_players") -- Get with default local value = ax.config:Get("optional.setting", "default_value") -- Get nested configuration local startingMoney = ax.config:Get("economy.starting_money") ``` -------------------------------- ### Schema File Organization Example Source: https://github.com/parallax-framework/parallax/blob/main/manuals/07-BEST_PRACTICES.md Organize schema files into logical directories such as 'core', 'config', 'factions', 'items', 'hooks', 'meta', and 'libraries' for better project structure. ```text schema/ ├── core/ -- Core schema systems ├── config/ -- Configuration files ├── factions/ -- Faction definitions ├── items/ -- Item definitions ├── hooks/ -- Hook overrides ├── meta/ -- Meta-tables └── libraries/ -- Custom libraries ``` -------------------------------- ### Configure Database Connection Source: https://github.com/parallax-framework/parallax/blob/main/manuals/04-ADVANCED_TOPICS.md Sets up the database connection parameters for the framework. Ensure you replace placeholder values with your actual MySQL credentials. ```lua -- parallax/gamemode/framework/libraries/sv_database.lua mysql:Configure({ host = "localhost", user = "gmod_user", pass = "your_password", database = "gmod_server", port = 3306 }) ``` -------------------------------- ### Helix Class Definition Example Source: https://github.com/parallax-framework/parallax/blob/main/manuals/backporting/helix/10-classes-and-attributes.md An example of a class definition in Helix, including name, description, faction, weapons, and validation/event methods. ```lua -- Helix (`schema/classes/sh_tcp.lua`) CLASS.name = "Transhuman Arm" CLASS.description = "The elite of the Overwatch." CLASS.faction = FACTION_MPF CLASS.isDefault = false CLASS.weapons = { "weapon_ar2", "weapon_frag", } function CLASS:CanSwitchTo(client) local char = client:GetCharacter() return char:GetData("canBecomeTCP", false) end function CLASS:OnSet(client) client:SetHealth(150) end CLASS_TCP = CLASS.index ``` -------------------------------- ### Client Initialization (gamemode/cl_init.lua) Source: https://github.com/parallax-framework/parallax/blob/main/manuals/01-ARCHITECTURE.md Initializes the Parallax framework on the client. It mirrors the server initialization by setting up the global namespace and including core framework files. ```lua DeriveGamemode("sandbox") -- Initialize global namespace ax = ax or {util = {}, config = {}, options = {}, character = {}, inventory = {}, item = {}} ax._reload = ax._reload or { pingAt = 0, armed = false, frame = -1 } -- Include client files include("framework/util/boot.lua") include("framework/boot.lua") ``` -------------------------------- ### Helix Schema Hook Example Source: https://github.com/parallax-framework/parallax/blob/main/manuals/backporting/helix/07-hooks.md Example of a schema hook method in Helix. This function is dispatched from the Schema table when the 'PlayerSay' hook is called. ```lua function Schema:PlayerSay(client, text) -- dispatched from the Schema table end ``` -------------------------------- ### Configure Server Settings Source: https://github.com/parallax-framework/parallax/blob/main/manuals/03-SCHEMA_DEVELOPMENT.md Set global server parameters like name, description, player limits, and gameplay rules. Ensure values are appropriate for your server's needs. ```lua -- schema/config/sh_config.lua -- Server settings ax.config:Set("server.name", "My Roleplay Server") ax.config:Set("server.description", "A custom roleplay server") ax.config:Set("server.max_players", 32) -- Gameplay settings ax.config:Set("playtime.enabled", true) ax.config:Set("playtime.interval", 60) -- Update every 60 seconds -- Economy settings ax.config:Set("economy.starting_money", 500) ax.config:Set("economy.max_money", 1000000) -- Character settings ax.config:Set("character.max_characters", 5) ax.config:Set("character.default_health", 100) -- Inventory settings ax.config:Set("inventory.default_weight", 30) ax.config:Set("inventory.weight_unit", "kg") ``` -------------------------------- ### Parallax Module Hook Example Source: https://github.com/parallax-framework/parallax/blob/main/manuals/backporting/helix/07-hooks.md Example of a module hook method in Parallax. This function is dispatched from the module's table when the 'PlayerSay' hook is called. ```lua function MODULE:PlayerSay(client, text) -- dispatched from ax.module.stored iteration end ``` -------------------------------- ### Initialize MySQL Database Source: https://github.com/parallax-framework/parallax/wiki/Database Configure the database connection details for MySQL. This should be placed in `schema/database.lua` or a similar initialization file. ```lua ax.database:Initialize({ host = "127.0.0.1", port = 3306, username = "root", password = "", database = "parallax" }) ``` -------------------------------- ### Build and Execute a SELECT Query Source: https://github.com/parallax-framework/parallax/blob/main/manuals/05-API_REFERENCE.md Demonstrates how to construct a SELECT query with WHERE and LIMIT clauses, and execute it with a callback function to process the results. Use this to fetch specific data from a table. ```lua local query = mysql:Select("ax_characters") query:Where("faction", FACTION_CITIZEN) query:Limit(10) query:Callback(function(result, status) if result then for i = 1, #result do print(result[i].name) end end end) query:Execute() ``` -------------------------------- ### Define a New Module Source: https://github.com/parallax-framework/parallax/blob/main/manuals/02-CORE_SYSTEMS.md Defines the basic metadata and initialization for a new module. This file should be named 'boot.lua' within the module's directory. ```lua -- modules/my_module/boot.lua MODULE = MODULE or {} MODULE.name = "My Module" MODULE.description = "A helpful module" MODULE.author = "YourName" -- Module initialization function MODULE:Initialize() -- Setup code ax.util:PrintSuccess("Module '" .. MODULE.name .. "' loaded!") end -- Module hooks function MODULE:OnSchemaLoaded() -- Schema loaded end function MODULE:OnPlayerSpawn(player) -- Player spawned end return MODULE ``` -------------------------------- ### Initialize Git Repository Source: https://github.com/parallax-framework/parallax/blob/main/manuals/07-BEST_PRACTICES.md Commands to initialize a new Git repository, add all files, make an initial commit, and create a new feature branch. ```bash git init git add . git commit -m "Initial commit" git checkout -b feature/new-faction ``` -------------------------------- ### Get Configuration Value - ax.config Source: https://github.com/parallax-framework/parallax/blob/main/manuals/05-API_REFERENCE.md Use ax.config:Get to retrieve configuration values. Provide the key as a string. An optional fallback value can be supplied, which will be returned if the key does not exist. ```lua local serverName = ax.config:Get("server.name") local maxPlayers = ax.config:Get("server.max_players", 32) ``` -------------------------------- ### Build Static Documentation Output Source: https://github.com/parallax-framework/parallax/blob/main/README.md Builds the static HTML output for the documentation. This command is typically used before deployment. ```bash mkdocs build ``` -------------------------------- ### SCHEMA Table Usage Example Source: https://github.com/parallax-framework/parallax/blob/main/manuals/01-ARCHITECTURE.md Illustrates how to define schema metadata using the global SCHEMA table. This includes setting the schema's name, description, and author. It also shows how to define a callback function, SCHEMA:OnSchemaLoaded, which is available after the schema has booted. ```lua -- schema/boot.lua SCHEMA.name = "My Schema" SCHEMA.description = "A custom roleplay schema" SCHEMA.author = "YourName" -- Available everywhere after boot function SCHEMA:OnSchemaLoaded() print("Schema loaded:", SCHEMA.name) end ``` -------------------------------- ### Get Item Definition or Instance Source: https://github.com/parallax-framework/parallax/blob/main/manuals/05-API_REFERENCE.md Use ax.item:Get to retrieve an item's definition by its class name or an item instance by its ID. Returns the item data or nil if not found. ```lua local itemDef = ax.item:Get("pistol") local itemInstance = ax.item:Get(123) ``` -------------------------------- ### Parallax Custom Hook Family Example Source: https://github.com/parallax-framework/parallax/blob/main/manuals/backporting/helix/07-hooks.md Example of a custom hook family method in Parallax, registered via `ax.hook:Register`. This function is dispatched from the 'SCHEMA' hook table when 'PlayerSay' is called. ```lua function SCHEMA:PlayerSay(client, text) -- dispatched from ax.hook.stored.SCHEMA end ``` -------------------------------- ### Correct YAML Formatting Example Source: https://github.com/parallax-framework/parallax/blob/main/manuals/intermediate/database_setup.md Shows the correct way to format the database.yml file with proper indentation, spacing, and quoting. This format is required for Parallax to parse the configuration correctly. ```yaml database: adapter: "mysqloo" hostname: "db.example.com" username: "test" password: "password" database: "parallax_db" port: 3306 ``` -------------------------------- ### Server Initialization (gamemode/init.lua) Source: https://github.com/parallax-framework/parallax/blob/main/manuals/01-ARCHITECTURE.md Initializes the Parallax framework on the server. It derives from the sandbox gamemode, sets up the global namespace, and includes necessary framework files. ```lua DeriveGamemode("sandbox") -- Initialize global namespace ax = ax or {util = {}, config = {}, options = {}, character = {}, inventory = {}, item = {}} ax._reload = ax._reload or { pingAt = 0, armed = false, frame = -1 } -- Send client files AddCSLuaFile("cl_init.lua") AddCSLuaFile("framework/util/boot.lua") AddCSLuaFile("framework/boot.lua") -- Include server files include("framework/util/boot.lua") include("framework/boot.lua") -- Add framework content resource.AddWorkshop(3479969076) -- Parallax Content ``` -------------------------------- ### Character Methods - Get Name Source: https://github.com/parallax-framework/parallax/blob/main/manuals/02-CORE_SYSTEMS.md Retrieve the name of the character. ```APIDOC ## character:GetName() ### Description Gets the name of the character. ### Returns - (string) The character's name. ``` -------------------------------- ### Example .gitignore Content Source: https://github.com/parallax-framework/parallax/blob/main/manuals/07-BEST_PRACTICES.md A sample .gitignore file to exclude common development artifacts like logs, database files, OS-specific files, and IDE configuration. ```text # Ignore GMod specific files .log .db # Ignore OS files .DS_Store Thumbs.db # Ignore IDE files .vscode/ .idea/ ``` -------------------------------- ### Schema Boot File Definition Source: https://github.com/parallax-framework/parallax/blob/main/manuals/03-SCHEMA_DEVELOPMENT.md Defines the basic metadata for your custom schema, such as its name, description, and author. This file is essential for identifying your schema within the framework. ```lua -- schema/boot.lua SCHEMA.name = "My Roleplay Schema" SCHEMA.description = "A custom roleplay schema based on Parallax." SCHEMA.author = "YourName" ``` -------------------------------- ### Character Methods - Get ID Source: https://github.com/parallax-framework/parallax/blob/main/manuals/02-CORE_SYSTEMS.md Retrieve the unique identifier of the character. ```APIDOC ## character:GetID() ### Description Gets the unique ID of the character. ### Returns - (number) The character's ID. ``` -------------------------------- ### Create and Configure an ax.button Source: https://github.com/parallax-framework/parallax/blob/main/manuals/08-UI_THEME_GUIDELINES.md This code creates a state-driven button with animated transitions. It shows how to set the button text, size it to its content, and dock it to the bottom with margin. ```lua local btn = panel:Add( "ax.button" ) btn:SetText( "Confirm" ) btn:SizeToContents() btn:Dock( BOTTOM ) btn:DockMargin( 0, ax.util:ScreenScaleH( 8 ), 0, 0 ) ``` -------------------------------- ### Get all factions Source: https://github.com/parallax-framework/parallax/blob/main/manuals/05-API_REFERENCE.md Retrieves a table containing all available factions in the system. ```lua local factions = ax.faction:GetAll() for id, faction in pairs(factions) do print(id, faction.name) end ``` -------------------------------- ### FACTION Table Usage Example Source: https://github.com/parallax-framework/parallax/blob/main/manuals/01-ARCHITECTURE.md Shows how to define a faction using the global FACTION table during file inclusion. This includes setting the faction's name, description, color, default status, and models. The framework automatically assigns an index and creates a global constant. ```lua -- schema/factions/sh_citizen.lua FACTION.name = "Citizen" FACTION.description = "Ordinary humans..." FACTION.color = Color(150, 150, 150) FACTION.isDefault = true FACTION.models = { "models/humans/group01/male_01.mdl", -- ... } -- Framework automatically sets FACTION.index and creates global -- Example: FACTION_CITIZEN = 1 ``` -------------------------------- ### Get Dominant Zone Source: https://github.com/parallax-framework/parallax/blob/main/gamemode/modules/zones/COMMANDS.md Retrieves the most dominant zone for a given entity. ```APIDOC ## Get Dominant Zone ### Description Determines and returns the primary or most influential zone affecting an entity. ### Method `ax.zones:GetDominant(entity)` ### Parameters #### Path Parameters - **entity** (Entity) - Required - The entity for which to find the dominant zone. ### Response #### Success Response - **dominantZone** (Zone) - The dominant zone object or identifier. ``` -------------------------------- ### Helix 'Load on boot' pattern Source: https://github.com/parallax-framework/parallax/blob/main/manuals/backporting/helix/09-data-persistence.md Illustrates the 'Load on boot' pattern in Helix using LoadData and SaveData hooks. ```lua function PLUGIN:LoadData() self.lookup = self:GetData() or {} end function PLUGIN:SaveData() self:SetData(self.lookup) end ``` -------------------------------- ### Creating Database Indexes Source: https://github.com/parallax-framework/parallax/blob/main/manuals/07-BEST_PRACTICES.md Add indexes to frequently queried fields to speed up data retrieval. This example shows how to create indexes on `faction`, `name`, and `inventory_id` columns. ```sql -- Add indexes manually to database CREATE INDEX idx_character_faction ON ax_characters(faction); CREATE INDEX idx_character_name ON ax_characters(name); CREATE INDEX idx_item_inventory ON ax_items(inventory_id); ``` -------------------------------- ### Character Methods - Get Owner Source: https://github.com/parallax-framework/parallax/blob/main/manuals/02-CORE_SYSTEMS.md Retrieve the player object that owns the character. ```APIDOC ## character:GetOwner() ### Description Gets the player object that owns this character. ### Returns - (Player) The player object who owns the character. ``` -------------------------------- ### Create Custom Storage Inventory Source: https://github.com/parallax-framework/parallax/blob/main/manuals/06-EXAMPLES.md Demonstrates how to create a custom storage inventory with a maximum weight and attach it to a physics prop. The container can be interacted with to open the inventory. ```lua -- Create a storage container inventory ax.inventory:Create({maxWeight = 100}, function(inventory) print("Created storage inventory:", inventory.id) -- Spawn a container entity local container = ents.Create("prop_physics") container:SetModel("models/props_junk/wood_crate001a.mdl") container:SetPos(Vector(0, 0, 0)) container:Spawn() container:SetNWInt("InventoryID", inventory.id) -- Add storage action container:SetUseType(SIMPLE_USE) function container:Use(activator, caller) if activator:IsPlayer() then ax.net:Start(activator, "open_storage", inventory.id) end end end) ``` -------------------------------- ### Create a Client-Side Custom Derma Panel Source: https://github.com/parallax-framework/parallax/blob/main/manuals/04-ADVANCED_TOPICS.md Creates a custom UI menu using Derma components on the client-side. This example shows how to create a frame, label, and button, and how to handle button clicks. ```lua -- Client-side custom UI local function OpenCustomMenu() local frame = vgui.Create("DFrame") frame:SetTitle("Custom Menu") frame:SetSize(400, 300) frame:Center() frame:MakePopup() local label = vgui.Create("DLabel", frame) label:SetText("Hello, World!") label:Dock(TOP) label:SetContentAlignment(5) label:SetHeight(30) local button = vgui.Create("DButton", frame) button:SetText("Click Me") button:Dock(BOTTOM) button.DoClick = function() chat.AddText("Button clicked!") end end -- Call from server command ax.net:Hook("open_menu", OpenCustomMenu) ``` -------------------------------- ### ax.item:Get Source: https://github.com/parallax-framework/parallax/blob/main/manuals/05-API_REFERENCE.md Retrieves an item's definition or instance based on its identifier. ```APIDOC ## ax.item:Get ### Description Get item definition or instance. ### Parameters #### Path Parameters - **identifier** (string|number): Item class or instance ID ### Returns - (table|nil): Item definition/instance or nil ### Example ```lua local itemDef = ax.item:Get("pistol") local itemInstance = ax.item:Get(123) ``` ``` -------------------------------- ### ax.faction:Get Source: https://github.com/parallax-framework/parallax/blob/main/manuals/05-API_REFERENCE.md Retrieves a faction based on its identifier, which can be an ID, index, or name. ```APIDOC ## ax.faction:Get(identifier) ### Description Get faction by ID, index, or name. ### Parameters #### Path Parameters - **identifier** (string|number): Faction identifier ### Returns - (table|nil): Faction table or nil ### Request Example ```lua local faction = ax.faction:Get("citizen") local faction = ax.faction:Get(1) ``` ``` -------------------------------- ### Get Visible Zones Source: https://github.com/parallax-framework/parallax/blob/main/gamemode/modules/zones/COMMANDS.md Retrieves the zones that are currently visible to a given entity. ```APIDOC ## Get Visible Zones ### Description Returns a list of zones that are considered visible to a specific entity. ### Method `ax.zones:VisibleZones(entity)` ### Parameters #### Path Parameters - **entity** (Entity) - Required - The entity for which to determine visible zones. ### Response #### Success Response - **visibleZones** (table) - A list of visible zone identifiers or zone objects. ``` -------------------------------- ### Add Launch Parameter for Schema Source: https://github.com/parallax-framework/parallax/wiki/Creating-a-Schema To test your schema, add the '+gamemode your-schema-name' launch parameter to your Garry's Mod startup options. ```bash +gamemode parallax-yourproject ``` -------------------------------- ### Get Zones at Position Source: https://github.com/parallax-framework/parallax/blob/main/gamemode/modules/zones/COMMANDS.md Retrieves all zones that contain the specified world position. ```APIDOC ## Get Zones at Position ### Description Retrieves a list of zones that are present at a given world position. ### Method `ax.zones:AtPos(position)` ### Parameters #### Path Parameters - **position** (Vector) - Required - The world position to check for zones. ### Response #### Success Response - **zones** (table) - A list of zone identifiers or zone objects found at the position. ``` -------------------------------- ### Schema Boot Loading Source: https://github.com/parallax-framework/parallax/blob/main/manuals/01-ARCHITECTURE.md Loads the schema's boot file, which is essential for initializing schema-specific configurations and systems. ```lua -- From ax.schema:Initialize() local active = SCHEMA.folder or engine.ActiveGamemode() local boot = ax.util:Include(active .. "/gamemode/schema/boot.lua", "shared") ``` -------------------------------- ### Get Usergroup Information Source: https://github.com/parallax-framework/parallax/blob/main/manuals/intermediate/usergroups.md Retrieves and displays detailed information about a specific registered usergroup. ```bash /UsergroupInfo "usergroup" ``` -------------------------------- ### Character Methods - Get Inventory ID Source: https://github.com/parallax-framework/parallax/blob/main/manuals/02-CORE_SYSTEMS.md Retrieve the ID of the character's inventory. ```APIDOC ## character:GetInventoryID() ### Description Gets the ID of the character's inventory. ### Returns - (number) The inventory ID. ``` -------------------------------- ### Server Schema Initialization Source: https://github.com/parallax-framework/parallax/blob/main/manuals/03-SCHEMA_DEVELOPMENT.md Initializes the Parallax gamemode on the server and adds custom content or workshop addons. Ensure `cl_init.lua` is added to client files. ```lua -- gamemode/init.lua AddCSLuaFile("cl_init.lua") DeriveGamemode("parallax") -- Add custom content resource.AddFile("materials/my_schema/banner.png") -- Add workshop content resource.AddWorkshop(123456789) ``` -------------------------------- ### Create and Restore Inventories in Helix Source: https://github.com/parallax-framework/parallax/blob/main/manuals/backporting/helix/08-inventory.md Demonstrates synchronous inventory creation and asynchronous restoration with a callback in Helix. Bag inventories require explicit registration. ```lua -- Create a new inventory of fixed size ix.inventory.Create(w, h, id) -- synchronous -- Restore an existing inventory from the database ix.inventory.Restore(invID, w, h, cb) -- async with callback -- Bag inventories have their own IDs registered via: ix.inventory.Register("bag_type", w, h, isBag) ``` -------------------------------- ### Character API - Get Character Source: https://github.com/parallax-framework/parallax/blob/main/manuals/02-CORE_SYSTEMS.md Retrieve a character object using its unique ID. ```APIDOC ## ax.character:Get(id) ### Description Retrieves a character object by its ID. ### Parameters - **id** (number) - The unique identifier of the character. ### Returns - (Character) The character object if found, otherwise nil. ``` -------------------------------- ### Item API Methods Source: https://github.com/parallax-framework/parallax/blob/main/manuals/02-CORE_SYSTEMS.md Demonstrates how to interact with the item system API to retrieve item definitions, instances, spawn items, transfer items, and get available actions. ```APIDOC ## Item API ```lua -- Get item definition by class local itemDef = ax.item:Get("pistol") -- Get item instance by ID local itemInstance = ax.item:Get(123) -- Spawn item in world (server) ax.item:Spawn("pistol", Vector(0, 0, 0), Angle(0, 0, 0), function(entity, itemObj) -- Callback when spawned end) -- Transfer item between inventories (server) local success, reason = ax.item:Transfer(item, fromInv, toInv, function(success) if success then print("Transfer complete") end end) -- Get item actions local actions = ax.item:GetActionsForClass("pistol") ``` ``` -------------------------------- ### Get Player Usergroup In-Game Source: https://github.com/parallax-framework/parallax/blob/main/manuals/intermediate/usergroups.md Use this in-game command to display the current usergroup of a player. ```bash /PlyGetUsergroup "player" ``` -------------------------------- ### Get Inventory Owner Source: https://github.com/parallax-framework/parallax/blob/main/manuals/02-CORE_SYSTEMS.md Retrieves the owner of the inventory. This could be a player, a container, or null if unowned. ```lua -- Get inventory owner local owner = inventory:GetOwner() ``` -------------------------------- ### Bootstrap First Admin via Console Source: https://github.com/parallax-framework/parallax/blob/main/manuals/intermediate/usergroups.md Use this command in the server console to set the initial admin usergroup for a player on a dedicated server. ```bash ax_player_set_usergroup "player" "superadmin" ``` -------------------------------- ### Get Inventory Weight Source: https://github.com/parallax-framework/parallax/blob/main/manuals/02-CORE_SYSTEMS.md Retrieves the current weight of the inventory. This is useful for checking against the maximum weight. ```lua -- Get inventory weight local weight = inventory:GetWeight() ``` -------------------------------- ### Create a New Faction Source: https://github.com/parallax-framework/parallax/blob/main/manuals/02-CORE_SYSTEMS.md Example of creating a new faction by defining its properties in a separate file. Includes precaching models and optional custom validation for joining. ```lua -- schema/factions/sh_citizen.lua FACTION.name = "Citizen" FACTION.description = "The oppressed populace under Combine rule." FACTION.color = Color(150, 150, 150) FACTION.isDefault = true -- New players start with this faction FACTION.models = { "models/humans/group01/male_01.mdl", "models/humans/group01/female_01.mdl", -- ... add more models } -- Precache models for performance for i = 1, #FACTION.models do util.PrecacheModel(FACTION.models[i]) end -- Optional: Custom validation function FACTION:CanBecome(client) if client:GetCharacter():GetVar("banned") then return false, "You are banned from this faction" end return true end ``` -------------------------------- ### Character API - Get Variable Source: https://github.com/parallax-framework/parallax/blob/main/manuals/02-CORE_SYSTEMS.md Retrieve the value of a character variable, with an optional fallback value. ```APIDOC ## character:GetVariable(variableName, fallback) ### Description Retrieves the value of a specific character variable. ### Parameters - **variableName** (string) - The name of the variable to retrieve. - **fallback** (any, optional) - The value to return if the variable is not found or has no value. ### Returns - (any) The value of the variable or the fallback value. ```