### Single Target Command Example in Lua Source: https://lyn.goobie.me/api/commands/creating-commands An example of a 'pm' (private message) command that enforces a single target, prevents self-messaging, and allows targeting higher-ranked players. It demonstrates custom parameter validation and message sending. ```lua Command("pm") :Permission("pm", Lyn.Role.Defaults()) :Param("player", { single_target = true, -- Only one player allowed cant_target_self = true, -- Can't message yourself allow_higher_target = true -- Can PM admins even if lower rank }) :Param("string", { hint = "message", check = function(ctx) return ctx.value and ctx.value:match("%S") ~= nil end }) :GetRestArgs() :Execute(function(caller, targets, message) local target = targets[1] Lyn.Player.Chat.Send(caller, "To " .. target:Name() .. ": " .. message) Lyn.Player.Chat.Send(target, "From " .. caller:Name() .. ": " .. message) end) :Add() ``` -------------------------------- ### String Parameter Type Example Source: https://lyn.goobie.me/api/commands/parameters A basic example of the 'string' parameter type, which accepts any text input without specific options. ```lua function send_message(ctx, message: string) -- Command logic using message end ``` -------------------------------- ### Player Targeting Command Example in Lua Source: https://lyn.goobie.me/api/commands/creating-commands A practical example of a 'heal' command that targets players, accepts an amount, and notifies all participants upon execution. It demonstrates parameter defaults and the use of LYN_NOTIFY. ```lua Command("heal") :Permission("heal", "admin") :Param("player", { default = "^" }) -- defaults to self :Param("number", { hint = "amount", default = 100, min = 1, max = 100000 }) :Execute(function(caller, targets, amount) for _, ply in ipairs(targets) do ply:SetHealth(amount) end LYN_NOTIFY("*", "#lyn.commands.heal.notify", { P = caller, T = targets, amount = amount }) end) :Add() ``` -------------------------------- ### Mixed Alias and Prefix Configuration in Lua Source: https://lyn.goobie.me/api/commands/prefixes Provides a comprehensive example of configuring a command ('pm') with multiple aliases, custom alias prefixes (including sticky and no-prefix options), permissions, parameters, and execution logic. ```lua Command("pm") :Aliases("msg", "whisper") :CustomAlias("/w", { chat_prefix = "", sticky = true }) :CustomAlias("tell", { console_prefix = "" }) :Permission("pm") :Param("player", { single_target = true, cant_target_self = true }) :Param("string", { hint = "message" }) :GetRestArgs() :Execute(function(caller, targets, message) local target = targets[1] Lyn.Player.Chat.Send(caller, "To " .. target:Name() .. ": " .. message) Lyn.Player.Chat.Send(target, "From " .. caller:Name() .. ": " .. message) end) :Add() ``` -------------------------------- ### Common Parameter Options Example Source: https://lyn.goobie.me/api/commands/parameters Demonstrates common options applicable to all parameter types, including setting a default value, making the parameter optional, providing a hint, and adding custom validation logic. ```lua function greet_user(ctx, name: string? { default = "Guest", optional = true, hint = "Enter your name", check = function(ctx) return string.len(ctx.args.name) > 2 end }) -- Command logic using name end ``` -------------------------------- ### Color Parameter Type Example Source: https://lyn.goobie.me/api/commands/parameters A simple example of the 'color' parameter type, which accepts color values in hex or string format. It has no type-specific options. ```lua function set_chat_color(ctx, color_value: color) -- Command logic using color_value end ``` -------------------------------- ### Execute Function Parameters in Lua Source: https://lyn.goobie.me/api/commands/creating-commands Explains how to define and access parameters within the command's execute function. It shows examples of different parameter types like 'player', 'number', and 'string', including optional parameters and hints. ```lua :Param("player") :Param("number", { hint = "amount" }) :Param("string", { hint = "reason", optional = true }) :Execute(function(caller, targets, amount, reason) -- caller: Player who ran the command -- targets: table of players (even single_target returns a table) -- amount: number value -- reason: string or nil end) ``` -------------------------------- ### Duration Parameter Type Example Source: https://lyn.goobie.me/api/commands/parameters Shows how to define a 'duration' parameter type with minimum and maximum duration constraints. Durations can be specified in minutes, hours, or seconds. ```lua function set_timer(ctx, duration: duration { min = "5m", max = "1h" }) -- Command logic using duration end ``` -------------------------------- ### Number Parameter Type Example Source: https://lyn.goobie.me/api/commands/parameters Illustrates the 'number' parameter type with options for setting minimum and maximum values, and controlling rounding behavior (round, floor, ceil, abs). ```lua function set_value(ctx, value: number { min = 1, max = 100, round = true }) -- Command logic using value end ``` -------------------------------- ### SteamID64 Parameter Type Example Source: https://lyn.goobie.me/api/commands/parameters Shows the 'steamid64' parameter type, which accepts both SteamID and SteamID64 formats. It has no type-specific options. ```lua function ban_player(ctx, player_id: steamid64) -- Command logic using player_id end ``` -------------------------------- ### Get Command by Name Source: https://lyn.goobie.me/api/commands/functions/Get Retrieves a command object by its name. Returns the command if found, otherwise returns nil. ```APIDOC ## GET /websites/lyn_goobie_me/command/{name} ### Description Gets a command by name. ### Method GET ### Endpoint `/websites/lyn_goobie_me/command/{name}` ### Parameters #### Path Parameters - **name** (string) - Required - The name of the command to retrieve. ### Response #### Success Response (200) - **Command** or **nil** - The command object if found, otherwise nil. #### Response Example ```json { "command_name": "example_command", "description": "This is an example command." } ``` #### Error Response (404) - **nil** - Returned when the command is not found. ``` -------------------------------- ### Player Data Retrieval Source: https://lyn.goobie.me/category/-functions Functions to get persistent data, playtime, session time, and variables for a player. ```APIDOC ## GET /websites/lyn_goobie_me/GetPData ### Description Gets persistent data for a player. ### Method GET ### Endpoint /websites/lyn_goobie_me/GetPData ### Parameters #### Query Parameters - **steamId64** (string) - Required - The SteamID64 of the player. - **key** (string) - Required - The key of the persistent data to retrieve. ### Response #### Success Response (200) - **value** (any) - The persistent data value associated with the key. #### Response Example ```json { "value": "some_data" } ``` ``` ```APIDOC ## GET /websites/lyn_goobie_me/GetPlayTime ### Description Returns the player's total playtime including the current session. ### Method GET ### Endpoint /websites/lyn_goobie_me/GetPlayTime ### Parameters #### Query Parameters - **steamId64** (string) - Required - The SteamID64 of the player. ### Response #### Success Response (200) - **playtimeSeconds** (integer) - The total playtime in seconds. #### Response Example ```json { "playtimeSeconds": 7200 } ``` ``` ```APIDOC ## GET /websites/lyn_goobie_me/GetSessionTime ### Description Returns how long the player has been on the server this session. ### Method GET ### Endpoint /websites/lyn_goobie_me/GetSessionTime ### Parameters #### Query Parameters - **steamId64** (string) - Required - The SteamID64 of the player. ### Response #### Success Response (200) - **sessionTimeSeconds** (integer) - The session time in seconds. #### Response Example ```json { "sessionTimeSeconds": 1800 } ``` ``` ```APIDOC ## GET /websites/lyn_goobie_me/GetSharedVar ### Description Retrieves a shared variable on a player. ### Method GET ### Endpoint /websites/lyn_goobie_me/GetSharedVar ### Parameters #### Query Parameters - **key** (string) - Required - The key of the shared variable. ### Response #### Success Response (200) - **value** (any) - The value of the shared variable. #### Response Example ```json { "value": "shared_value" } ``` ``` ```APIDOC ## GET /websites/lyn_goobie_me/GetVar ### Description Retrieves a variable on the player in the current state. ### Method GET ### Endpoint /websites/lyn_goobie_me/GetVar ### Parameters #### Query Parameters - **steamId64** (string) - Required - The SteamID64 of the player. - **key** (string) - Required - The key of the variable. ### Response #### Success Response (200) - **value** (any) - The value of the variable. #### Response Example ```json { "value": "player_specific_value" } ``` ``` -------------------------------- ### Role Parameter Type Example Source: https://lyn.goobie.me/api/commands/parameters Demonstrates the 'role' parameter type, which is used to specify a role name from Lyn roles. It does not have any type-specific options. ```lua function assign_role(ctx, role_name: role) -- Command logic using role_name end ``` -------------------------------- ### Map Parameter Type Example Source: https://lyn.goobie.me/api/commands/parameters Illustrates the 'map' parameter type for specifying map names, with an option to exclude the current map. ```lua function change_map(ctx, map_name: map { exclude_current = true }) -- Command logic using map_name end ``` -------------------------------- ### Player Parameter Type Example Source: https://lyn.goobie.me/api/commands/parameters Demonstrates how to define a 'player' parameter type, including options for single target, preventing self-targeting, and allowing higher target immunity. It also shows common selectors like self, eye trace, all, steamid, userid, and name. ```lua function my_command(ctx, target_player: player { single_target = true, cant_target_self = true, allow_higher_target = true }) -- Command logic using target_player end ``` -------------------------------- ### Override Command Prefixes in Lua Source: https://lyn.goobie.me/api/commands/prefixes Illustrates how to set custom chat and console prefixes for an entire command, overriding any global defaults. For example, setting chat prefix to '/' and console prefix to 'sv_'. ```lua Command("rcon") :ChatPrefix("/") :ConsolePrefix("sv_") :Execute(function(caller, cmd) -- ... end) :Add() ``` -------------------------------- ### Custom String Parameter Validation with Lua Source: https://lyn.goobie.me/api/commands/creating-commands Demonstrates how to implement custom validation logic for string parameters within a command. The example enforces that the string must not be empty or whitespace and has a maximum length of 200 characters, returning false if validation fails. ```lua :Param("string", { hint = "message", check = function(ctx) local value = ctx.value -- Must not be empty/whitespace if not value or not value:match("%S") then return false end -- Max 200 characters if #value > 200 then return false end return true end }) ``` -------------------------------- ### Get Parameter Definition using Lyn.Command.GetParam Source: https://lyn.goobie.me/api/commands/functions/GetParam Retrieves a parameter type definition by its name. This function is part of the Lyn.Command module and returns either a Parameter object or nil if the parameter is not found. ```go func Lyn.Command.GetParam(name string) Parameter | nil ``` -------------------------------- ### Lyn Role Data Structure Example Source: https://lyn.goobie.me/api/role/structure This snippet demonstrates the typical structure of a role object in Lyn. It includes fields for name, display name, immunity level, color representation, an optional parent role ('extends'), and a table of permissions. Note that 'extends' and 'permissions' can be nil. ```lua { name = "admin", display_name = "Admin", immunity = 50, color = Color(255, 0, 0), -- can be nil extends = "user", -- can be nil permissions = { ["freeze"] = true, ["goto"] = true, ["bring"] = false } } ``` -------------------------------- ### Get Players by Permission - Lua Source: https://lyn.goobie.me/api/player/functions/GetAllWithPermission Retrieves all players possessing a specific permission. It takes a string representing the permission as input and returns a table (array) of player objects. Each player object in the returned array can be iterated over to access player-specific information, such as their nickname. ```lua local admins = Lyn.Player.GetAllWithPermission("testest") for _, ply in ipairs(admins) do print(ply:Nick()) end ``` -------------------------------- ### Permission Management in Lua Source: https://lyn.goobie.me/api/commands/creating-commands Illustrates various ways to set permissions for commands, including single default roles, multiple default roles, all roles, and omitting permissions for public access. ```lua -- Permission with default role :Permission("kick", "admin") -- Permission with multiple default roles :Permission("vote", {"user", "vip"}) -- Permission with all roles (using Lyn.Role.Defaults()) :Permission("pm", Lyn.Role.Defaults()) -- No permission (anyone can use) -- Simply omit :Permission() ``` -------------------------------- ### Setting Command Categories in Lua Source: https://lyn.goobie.me/api/commands/creating-commands Demonstrates how to group commands into categories for better organization, particularly for menu display. Commands can inherit a category or have it overridden on a per-command basis. ```lua Command.SetCategory("Fun") -- All commands below inherit this category Command("slap"):Category("Fun") -- or override per-command ``` -------------------------------- ### Display MOTD/Rules Page with Lua Source: https://lyn.goobie.me/api/commands/creating-commands Creates a command to display a Message of the Day (MOTD) or rules page. It triggers a server-side event to show the MOTD and uses client-side hooks to create and display a DHTML panel with a specified URL. It leverages Net.StartSV and Net.HookCL for communication. ```lua local Net = Lyn.GoobieCore.Net Command("motd") :Aliases("rules", "info") :DenyConsole() :NoConsoleLog() :Execute(function(ply) Net.StartSV("MOTD.Show", ply) end) :Add() if CLIENT then Net.HookCL("MOTD.Show", function() -- Open your custom MOTD panel local frame = vgui.Create("DFrame") frame:SetSize(600, 400) frame:Center() frame:MakePopup() frame:SetTitle("Server Rules") local html = frame:Add("DHTML") html:Dock(FILL) html:OpenURL("https://yourserver.com/rules") end) end ``` -------------------------------- ### Lyn.Command.GetAll() Source: https://lyn.goobie.me/api/commands/functions/GetAll Retrieves a dictionary of all registered commands, mapping command names to their respective objects. ```APIDOC ## Lyn.Command.GetAll() ### Description Returns all registered commands. ### Method `table` (Function) ### Endpoint N/A (Local function) ### Parameters None ### Request Example N/A ### Response #### Success Response (table) - **command name** (string) - The name of the registered command. - **command object** (table) - The object representing the command. #### Response Example ```lua { ["command1"] = { ... }, ["command2"] = { ... } } ``` ``` -------------------------------- ### Lyn.Player.RetrieveDataTransaction Hook Source: https://lyn.goobie.me/api/player/hooks/RetrieveDataTransaction This hook is invoked before a player's data retrieval transaction initiates. It allows for pre-transaction data setup and can be used within a coroutine. ```APIDOC ## Lyn.Player.RetrieveDataTransaction Hook ### Description Called before a player's auth, data retrieval transaction begins. You can use this hook to set up any necessary data before "Lyn.Player.Auth" is called. You are inside a coroutine, so you can yield inside this hook if needed. The `txn` functions already yield internally, so you don't need to yield when using them. ### Method Hook ### Endpoint N/A (Hook) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```lua hook.Add("Lyn.Player.RetrieveDataTransaction", "MyRetrieveDataTransactionHook", function(ply, steamid64, txn) if not ply:IsValid() then return end local err, res = txn:Fetch([[SELECT {1};]], params = { ply:SteamID64() }) if err then return err end Lyn.Player.SetVar(ply, "MyData", res) end) ``` ### Response #### Success Response No direct response, but can return an error string. #### Response Example `string | nil`: An error message in case of failure, or nil on success. Can be anything that works with `tostring()`. ``` -------------------------------- ### Timed Action Command with Reason in Lua Source: https://lyn.goobie.me/api/commands/creating-commands Shows how to implement commands involving timed actions and optional reasons, such as muting a player. It utilizes `:GetRestArgs()` to capture multi-word reasons and formats notification data. ```lua Command("mute") :Permission("mute", "admin") :Param("player") :Param("duration", { default = "5m", min = 0 }) :Param("string", { hint = "reason", optional = true }) :GetRestArgs() -- Allows spaces in reason without quotes :Execute(function(caller, targets, duration, reason) if not reason then reason = Lyn.I18n.t("#lyn.unspecified") end for _, ply in ipairs(targets) do -- Apply mute logic end LYN_NOTIFY("*", "#lyn.commands.mute.notify", { P = caller, T = targets, D = duration, reason = reason }) end) :Add() ``` -------------------------------- ### Basic Command Structure in Lua Source: https://lyn.goobie.me/api/commands/creating-commands Defines the fundamental structure for creating a new command using Lyn.Command. It includes setting the command name, permissions, parameters, and the execution function. The :Add() method is crucial for registering the command. ```lua local Command = Lyn.Command Command("commandname") :Permission("permission_name", "default_role") :Param("type", { options }) :Execute(function(caller, arg1, arg2, ...) -- Your code here end) :Add() ``` -------------------------------- ### Player and Role Fetching Source: https://lyn.goobie.me/category/-functions Functions to fetch players by role, player roles, and permissions. ```APIDOC ## GET /websites/lyn_goobie_me/FetchByRole ### Description Fetches all players that have a specific role. ### Method GET ### Endpoint /websites/lyn_goobie_me/FetchByRole ### Parameters #### Query Parameters - **roleName** (string) - Required - The name of the role to fetch players for. ### Response #### Success Response (200) - **players** (array) - An array of SteamID64s of players with the specified role. #### Response Example ```json { "players": [ "76561198000000001", "76561198000000002" ] } ``` ``` ```APIDOC ## GET /websites/lyn_goobie_me/FetchRoles ### Description Fetches the roles of the player using their SteamID64. ### Method GET ### Endpoint /websites/lyn_goobie_me/FetchRoles ### Parameters #### Query Parameters - **steamId64** (string) - Required - The SteamID64 of the player. ### Response #### Success Response (200) - **roles** (array) - An array of role names the player has. #### Response Example ```json { "roles": [ "admin", "moderator" ] } ``` ``` ```APIDOC ## GET /websites/lyn_goobie_me/GetAllWithPermission ### Description Returns all players that have a specific permission. ### Method GET ### Endpoint /websites/lyn_goobie_me/GetAllWithPermission ### Parameters #### Query Parameters - **permissionName** (string) - Required - The name of the permission to check. ### Response #### Success Response (200) - **players** (array) - An array of SteamID64s of players with the specified permission. #### Response Example ```json { "players": [ "76561198000000001", "76561198000000003" ] } ``` ``` -------------------------------- ### Get Player Immunity Level - Lua Source: https://lyn.goobie.me/api/player/functions/Role Retrieves the immunity level of the highest role assigned to a target player. Returns 0 if the player has no roles. Requires a valid Player object as input. ```Lua print(Lyn.Player.Role.GetImmunity(Entity(1))) -- Output: -- 100 ``` -------------------------------- ### Open Hidden UI Menu with Lua Source: https://lyn.goobie.me/api/commands/creating-commands Defines a command that opens a hidden UI menu or custom interface. It uses Net.StartSV to initiate a server-side event and Net.HookCL to handle the client-side response for opening the menu. Console logging and menu visibility are controlled. ```lua local Net = Lyn.GoobieCore.Net Command("menu") :DenyConsole() -- Can't run from console :NoConsoleLog() -- Don't log to console :NoMenu() -- Hide from command menu :Execute(function(ply) Net.StartSV("Menu.Open", ply) end) :Add() if CLIENT then Net.HookCL("Menu.Open", function() Lyn.Menu.Open() end) end ``` -------------------------------- ### Define Simple Command Aliases in Lua Source: https://lyn.goobie.me/api/commands/prefixes Demonstrates how to create a command named 'teleport' and assign multiple aliases ('tp', 'goto', 'warp') to it using the Lua API. All aliases inherit the command's global prefixes. ```lua Command("teleport") :Aliases("tp", "goto", "warp") :Execute(function(caller, targets, destination) -- ... end) :Add() ``` -------------------------------- ### Get Player Persistent Data (Lyn Script) Source: https://lyn.goobie.me/api/player/functions/GetPData Retrieves persistent data associated with a specific player using a given key. If the key is not found, a default value is returned. This function is part of the Lyn.Player module. ```Lyn Script any Lyn.Player.GetPData(Player ply, string key, any default) ``` -------------------------------- ### Player Permission and Authentication Checks Source: https://lyn.goobie.me/category/-functions Functions to check player permissions and authentication status. ```APIDOC ## GET /websites/lyn_goobie_me/HasPermission ### Description Checks if the player has a specific permission. ### Method GET ### Endpoint /websites/lyn_goobie_me/HasPermission ### Parameters #### Query Parameters - **steamId64** (string) - Required - The SteamID64 of the player. - **permissionName** (string) - Required - The name of the permission to check. ### Response #### Success Response (200) - **hasPermission** (boolean) - True if the player has the permission, false otherwise. #### Response Example ```json { "hasPermission": true } ``` ``` ```APIDOC ## GET /websites/lyn_goobie_me/IsAuthed ### Description Checks if the player has been authenticated by Lyn. ### Method GET ### Endpoint /websites/lyn_goobie_me/IsAuthed ### Parameters #### Query Parameters - **steamId64** (string) - Required - The SteamID64 of the player. ### Response #### Success Response (200) - **isAuthenticated** (boolean) - True if the player is authenticated, false otherwise. #### Response Example ```json { "isAuthenticated": true } ``` ``` ```APIDOC ## GET /websites/lyn_goobie_me/IsNetReady ### Description Checks if the player is ready to receive netmessages. ### Method GET ### Endpoint /websites/lyn_goobie_me/IsNetReady ### Parameters #### Query Parameters - **steamId64** (string) - Required - The SteamID64 of the player. ### Response #### Success Response (200) - **isNetReady** (boolean) - True if the player is ready for netmessages, false otherwise. #### Response Example ```json { "isNetReady": true } ``` ``` ```APIDOC ## GET /websites/lyn_goobie_me/IsSteamAuthed ### Description Checks if the player is Steam authenticated. ### Method GET ### Endpoint /websites/lyn_goobie_me/IsSteamAuthed ### Parameters #### Query Parameters - **steamId64** (string) - Required - The SteamID64 of the player. ### Response #### Success Response (200) - **isSteamAuthenticated** (boolean) - True if the player is Steam authenticated, false otherwise. #### Response Example ```json { "isSteamAuthenticated": true } ``` ``` -------------------------------- ### Get Player Session Time (Lua) Source: https://lyn.goobie.me/api/player/functions/GetSessionTime Retrieves the duration a player has been connected to the server for the current session. This function takes a Player object as input and returns a number representing the session time in seconds. No specific dependencies are mentioned beyond the Lyn.Player library. ```Lua number Lyn.Player.GetSessionTime(Player ply) ``` -------------------------------- ### Custom Alias Prefixes with Sticky Matching in Lua Source: https://lyn.goobie.me/api/commands/prefixes Shows how to define a command with a custom alias prefix ('@') that has no chat prefix and is sticky. This allows for symbol-based shortcuts like '@message'. ```lua Command("adminsay") :CustomAlias("@", { chat_prefix = "", sticky = true }) :Param("string", { hint = "message" }) :GetRestArgs() :Execute(function(caller, message) -- ... end) :Add() ``` -------------------------------- ### Role Management Source: https://lyn.goobie.me/category/-functions Functions for adding, retrieving, and managing player roles. ```APIDOC ## POST /websites/lyn_goobie_me/Role.Add ### Description Adds the specified role to the player for an optional duration (in seconds). ### Method POST ### Endpoint /websites/lyn_goobie_me/Role.Add ### Parameters #### Query Parameters - **steamId64** (string) - Required - The SteamID64 of the player. - **roleName** (string) - Required - The name of the role to add. - **durationSeconds** (integer) - Optional - The duration in seconds for the role. If omitted or 0, the role is permanent. ### Request Example ```json { "steamId64": "76561198000000001", "roleName": "vip", "durationSeconds": 3600 } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the role was added successfully. #### Response Example ```json { "success": true } ``` ``` ```APIDOC ## POST /websites/lyn_goobie_me/Role.AddSteamID64 ### Description Adds the specified role to the player for an optional duration (in seconds) using their SteamID64. ### Method POST ### Endpoint /websites/lyn_goobie_me/Role.AddSteamID64 ### Parameters #### Query Parameters - **steamId64** (string) - Required - The SteamID64 of the player. - **roleName** (string) - Required - The name of the role to add. - **durationSeconds** (integer) - Optional - The duration in seconds for the role. If omitted or 0, the role is permanent. ### Request Example ```json { "steamId64": "76561198000000001", "roleName": "moderator", "durationSeconds": 0 } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the role was added successfully. #### Response Example ```json { "success": true } ``` ``` ```APIDOC ## GET /websites/lyn_goobie_me/Role.Get ### Description Returns the highest role the specified player has. ### Method GET ### Endpoint /websites/lyn_goobie_me/Role.Get ### Parameters #### Query Parameters - **steamId64** (string) - Required - The SteamID64 of the player. ### Response #### Success Response (200) - **highestRole** (string) - The name of the player's highest role. #### Response Example ```json { "highestRole": "admin" } ``` ``` ```APIDOC ## GET /websites/lyn_goobie_me/Role.GetAll ### Description Returns a copy of all roles the specified player has. ### Method GET ### Endpoint /websites/lyn_goobie_me/Role.GetAll ### Parameters #### Query Parameters - **steamId64** (string) - Required - The SteamID64 of the player. ### Response #### Success Response (200) - **roles** (array) - An array of role names the player possesses. #### Response Example ```json { "roles": [ "admin", "vip" ] } ``` ``` ```APIDOC ## GET /websites/lyn_goobie_me/Role.GetColor ### Description Returns the color of the highest role the specified player has. ### Method GET ### Endpoint /websites/lyn_goobie_me/Role.GetColor ### Parameters #### Query Parameters - **steamId64** (string) - Required - The SteamID64 of the player. ### Response #### Success Response (200) - **color** (string) - The color associated with the player's highest role (e.g., hex code or name). #### Response Example ```json { "color": "#FF0000" } ``` ``` ```APIDOC ## GET /websites/lyn_goobie_me/Role.GetDisplay ### Description Returns the display name of the highest role the specified player has. ### Method GET ### Endpoint /websites/lyn_goobie_me/Role.GetDisplay ### Parameters #### Query Parameters - **steamId64** (string) - Required - The SteamID64 of the player. ### Response #### Success Response (200) - **displayName** (string) - The display name of the player's highest role. #### Response Example ```json { "displayName": "Administrator" } ``` ``` ```APIDOC ## GET /websites/lyn_goobie_me/Role.GetImmunity ### Description Returns the immunity level of the highest role the specified player has. ### Method GET ### Endpoint /websites/lyn_goobie_me/Role.GetImmunity ### Parameters #### Query Parameters - **steamId64** (string) - Required - The SteamID64 of the player. ### Response #### Success Response (200) - **immunity** (integer) - The immunity level of the player's highest role. #### Response Example ```json { "immunity": 100 } ``` ``` ```APIDOC ## GET /websites/lyn_goobie_me/Role.Has ### Description Returns whether the specified player has the given role(s). Supports string, array-style, and dictionary-style table inputs. ### Method GET ### Endpoint /websites/lyn_goobie_me/Role.Has ### Parameters #### Query Parameters - **steamId64** (string) - Required - The SteamID64 of the player. - **roleNames** (string or array) - Required - The name(s) of the role(s) to check for. ### Response #### Success Response (200) - **hasRole** (boolean) - True if the player has at least one of the specified roles, false otherwise. #### Response Example ```json { "hasRole": true } ``` ``` ```APIDOC ## GET /websites/lyn_goobie_me/Role.HasDeep ### Description Returns whether the specified player has the given role or any roles that inherit from it. ### Method GET ### Endpoint /websites/lyn_goobie_me/Role.HasDeep ### Parameters #### Query Parameters - **steamId64** (string) - Required - The SteamID64 of the player. - **roleName** (string) - Required - The name of the role to check for. ### Response #### Success Response (200) - **hasDeepRole** (boolean) - True if the player has the role or an inheriting role, false otherwise. #### Response Example ```json { "hasDeepRole": true } ``` ``` ```APIDOC ## GET /websites/lyn_goobie_me/Role.Iter ### Description Returns an iterator for all roles the specified player has. ### Method GET ### Endpoint /websites/lyn_goobie_me/Role.Iter ### Parameters #### Query Parameters - **steamId64** (string) - Required - The SteamID64 of the player. ### Response #### Success Response (200) - **rolesIterator** (iterator) - An iterator object that can be used to loop through the player's roles. #### Response Example ```json { "rolesIterator": "" } ``` ``` -------------------------------- ### Lyn.Role.Create Source: https://lyn.goobie.me/api/role/functions/Create Creates a new role with specified attributes and an optional callback for completion status. ```APIDOC ## POST /websites/lyn_goobie_me/roles ### Description Creates a new role with the provided name, immunity level, and optional display name, color, and extension. A callback function can be provided to handle the operation's success or failure. ### Method POST ### Endpoint /websites/lyn_goobie_me/roles ### Parameters #### Request Body - **name** (string) - Required - The unique name for the role. - **immunity** (number) - Required - The immunity level associated with the role. - **display_name** (string | nil) - Optional - A human-readable display name for the role. - **color** (Color | nil) - Optional - The color associated with the role, represented by a Color object. - **extends** (string | nil) - Optional - The name of another role that this role extends. - **callback** (function | nil) - Optional - A function to be called upon completion. It receives an error message (string or nil) as its only argument. ### Request Example ```json { "name": "admin", "immunity": 100, "display_name": "Administrator", "color": {"r": 255, "g": 0, "b": 0}, "extends": "user" } ``` ### Response #### Success Response (200) - **message** (string) - A success message indicating the role was created. #### Response Example ```json { "message": "Role 'admin' created successfully." } ``` #### Error Response (400) - **error** (string) - An error message detailing why the role creation failed. #### Error Response Example ```json { "error": "Role with name 'admin' already exists." } ``` ``` -------------------------------- ### Create UI Theme in Lua Source: https://lyn.goobie.me/themes Defines a new UI theme by returning a table with a name and color definitions. Supports internationalization via Lyn.I18n.Register. Colors can be specified as hex strings or Color objects. ```lua Lyn.I18n.Register({ en = { themes = { ["My Theme"] = "My Theme", }, }, ["zh-cn"] = { themes = { ["My Theme"] = "我的主题", }, }, }) return { name = "My Theme", blur = true, -- Base surfaces ["bg"] = "#1A1B1EBB", ["bg-200"] = "#3E3F42BB", ["bg-300"] = "#2C2D30BB", ["fg"] = "#F0F2F5", ["fg-200"] = "#C5CEDC", ["fg-300"] = "#8A939E", -- Primary ["primary"] = "#5B21B6", ["primary-200"] = "#6A28D9", ["primary-300"] = "#7537E1", ["primary-fg"] = "#F5F0FF", ["primary-200-fg"] = "#FAF8FF", ["primary-300-fg"] = "#FFFFFF", -- Accent ["accent"] = "#0A6B75", ["accent-200"] = "#14B8A6", ["accent-fg"] = "#F4FEFF", ["accent-200-fg"] = "#F0FFFF", -- Error / Success / Warning ["error"] = "#D33732", ["error-fg"] = "#f8f8f2", ["success"] = "#28a745", ["success-fg"] = "#f8fdf9", ["warning"] = "#fcb700", ["warning-fg"] = "#2d2006", } ``` ```lua ["bg"] = Color(26, 27, 30, 187) ``` -------------------------------- ### Command Search API Source: https://lyn.goobie.me/api/commands/functions/Search Searches for a command by name or alias, supporting prefix matching. It returns the matched command or nil if no command is found. ```APIDOC ## POST /websites/lyn_goobie_me/search ### Description Searches for a command by name or alias (including prefixes). ### Method POST ### Endpoint /websites/lyn_goobie_me/search ### Parameters #### Query Parameters - **query** (string) - Required - The name or alias of the command to search for. ### Request Body This endpoint does not accept a request body. ### Response #### Success Response (200) - **command** (Command | nil) - The matched command object or nil if no command is found. #### Response Example ```json { "command": { "name": "exampleCommand", "aliases": ["ex", "cmd"] } } ``` #### Error Response (No specific error responses defined in the provided documentation. Standard HTTP error codes may apply.) ``` -------------------------------- ### Fetch Players by Role (Lua) Source: https://lyn.goobie.me/api/player/functions/FetchByRole Fetches all players associated with a specific role. Accepts an optional table of fields to include in the response (e.g., 'name', 'playtime'). Requires a callback function to handle the results or errors. ```Lua -- Basic usage (steamid64 only) Lyn.Player.FetchByRole("admin", function(err, players) if err then -- database error already printed in console by Lyn print("Error fetching players") return end PrintTable(players) --[[ { { steamid64 = "76561198261855442" }, { steamid64 = "76561198000000000" } } ]] end) -- With included fields Lyn.Player.FetchByRole("admin", {"name", "playtime"}, function(err, players) if err then -- database error already printed in console by Lyn print("Error fetching players") return end PrintTable(players) --[[ { { steamid64 = "76561198261855442", name = "Srlion", playtime = 5000 }, { steamid64 = "76561198000000000", name = "", playtime = 0 } } ]] end) ``` -------------------------------- ### Define Constants - Lua Source: https://lyn.goobie.me/api/constants Shows the syntax for defining new constants within a Lua file in the `lua/lyn/sh_constants/` directory. Each `C` call registers a new network identifier. ```lua C "Lyn.Role.SetCommandParamConstraints" C "Lyn.Role.PreSetExtends" C "Lyn.Role.SetExtends" ``` -------------------------------- ### Lyn.Player.IsNetReady Source: https://lyn.goobie.me/api/player/functions/IsNetReady Checks if a player is ready to receive netmessages. This is useful for ensuring that network operations are performed only when the player's connection is stable. ```APIDOC ## Lyn.Player.IsNetReady ### Description Checks if the player is ready to receive netmessages. ### Method GET ### Endpoint /websites/lyn_goobie_me/Lyn.Player.IsNetReady ### Parameters #### Path Parameters - **ply** (Player) - Required - The player object to check. ### Request Example ```json { "ply": "player_object_id" } ``` ### Response #### Success Response (200) - **isNetReady** (boolean) - True if the player is ready to receive netmessages, false otherwise. #### Response Example ```json { "isNetReady": true } ``` ``` -------------------------------- ### Player Sound Playback Source: https://lyn.goobie.me/category/-functions Function to play a sound for a specific player. ```APIDOC ## POST /websites/lyn_goobie_me/PlaySound ### Description Plays a sound for a specific player. ### Method POST ### Endpoint /websites/lyn_goobie_me/PlaySound ### Parameters #### Query Parameters - **steamId64** (string) - Required - The SteamID64 of the player. - **soundName** (string) - Required - The name of the sound to play. ### Request Example ```json { "steamId64": "76561198000000001", "soundName": "ui/alert.wav" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the sound playback was initiated successfully. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Broadcasting Command Notifications in Lua Source: https://lyn.goobie.me/api/commands/creating-commands Covers the use of LYN_NOTIFY to broadcast command results to various recipients, including everyone, specific players, or just the caller. It details how to pass custom data for translation placeholders. ```lua -- Notify everyone LYN_NOTIFY("*", "#lyn.commands.heal.notify", { P = caller, -- {P} in translation = caller name T = targets, -- {T} in translation = target names amount = 100 -- %amount% in translation }) -- Notify specific players LYN_NOTIFY(targets, "#lyn.commands.pm.received", { message = msg }) -- Notify caller only LYN_NOTIFY(caller, "#lyn.commands.error.not_found") ``` -------------------------------- ### Assign Player Role with Lua Source: https://lyn.goobie.me/api/commands/creating-commands Defines a command to assign a role to a player, with optional duration. It includes permission checks and custom validation for the role parameter, ensuring the caller can assign the specified role. Handles errors and sends notifications upon successful assignment. ```lua Command("giverole") :Permission("giverole") :Param("player", { single_target = true }) :Param("role", { check = function(ctx) -- Only allow roles the caller can target return ctx.value and ctx.caller:CanTargetRole(ctx.value) end }) :Param("duration", { default = 0 }) :Execute(function(caller, targets, role, duration) local target = targets[1] Lyn.Player.Role.Add(target, role, duration, function(err) if err then Lyn.Player.Chat.Send(caller, "#lyn.commands_core.failed_to_run") return end LYN_NOTIFY("*", "#lyn.commands.giverole.notify", { P = caller, T = targets, role = Lyn.Role.GetDisplayName(role), D = duration }) end) end) :Add() ``` -------------------------------- ### Lyn.Player.FetchByRole Source: https://lyn.goobie.me/api/player/functions/FetchByRole Fetches all players that have a specific role. It supports optional parameters to include specific fields and a callback function to handle the response. ```APIDOC ## Lyn.Player.FetchByRole ### Description Fetches all players that have a specific role. ### Method Server Function ### Endpoint `Lyn.Player.FetchByRole(string role, table? include, function callback)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```lua -- Basic usage (steamid64 only) Lyn.Player.FetchByRole("admin", function(err, players) if err then -- database error already printed in console by Lyn print("Error fetching players") return end PrintTable(players) --[[ { { steamid64 = "76561198261855442" }, { steamid64 = "76561198000000000" } } ]] end) -- With included fields Lyn.Player.FetchByRole("admin", {"name", "playtime"}, function(err, players) if err then -- database error already printed in console by Lyn print("Error fetching players") return end PrintTable(players) --[[ { { steamid64 = "76561198261855442", name = "Srlion", playtime = 5000 }, { steamid64 = "76561198000000000", name = "", playtime = 0 } } ]] end) ``` ### Response #### Success Response (200) - **players** (table) - Array of players with the specified role. #### Error Response - **err** (table | nil) - Error message if the operation failed. #### Response Example ```json { "players": [ { "steamid64": "76561198261855442", "name": "Srlion", "playtime": 5000 }, { "steamid64": "76561198000000000", "name": "", "playtime": 0 } ] } ``` ```