### Oxide Plugin Example Source: https://carbonmod.gg/devs/creating-your-first-plugin A basic example of an Oxide-compatible plugin. ```csharp namespace Oxide.Plugins; [Info("MyPlugin", "", "1.0.0")] [Description("")] public class MyPlugin : RustPlugin { private void OnServerInitialized() { Puts("Hello world!"); } } ``` -------------------------------- ### Full Example Plugin Source: https://carbonmod.gg/tutorials/beginners-guide/localization A complete example of a CarbonMod plugin demonstrating localization features. ```csharp using System.Collections.Generic; namespace Oxide.Plugins; [Info("HelloThere", "Bubbafett", "1.0.1")] [Description("Cool plugin that tells players about cool permissions.")] public class HelloThere : RustPlugin { public const string PermUse = "HelloThere.use"; protected override void LoadDefaultMessages() { lang.RegisterMessages(new Dictionary { ["Hello"] = "Hello there!", ["NoPerm"] = "You do not have permission to use this command.", ["Welcome"] = "Welcome to the server, {0}!", }, this, "en"); } private void Init() { cmd.AddChatCommand("hi", this, nameof(CmdHello)); permission.RegisterPermission(PermUse, this); } private void LangMessage(BasePlayer player, string key) { player.ChatMessage(lang.GetMessage(key, this, player.UserIDString)); } private void LangMessage(BasePlayer player, string key, params string[] args) { player.ChatMessage(string.Format(lang.GetMessage(key, this, player.UserIDString),args)); } private void CmdHello(BasePlayer player, string command, string[] args) { if(!permission.UserHasPermission(player.UserIDString, PermUse)) { LangMessage(player, "NoPerm"); return; } LangMessage(player, "Hello"); LangMessage(player,"Welcome", player.displayName); } } ``` -------------------------------- ### Example Config Source: https://carbonmod.gg/tutorials/beginners-guide/config-management An example of a JSON configuration file for the WhiteList Module from Carbon. ```json // Config of the WhiteList Module from Carbon { "Enabled": false, "Config": { "BypassPermission": "whitelist.bypass", "BypassGroup": "whitelisted" }, "Version": "781308331" } ``` -------------------------------- ### Windows Installation Source: https://carbonmod.gg/owners/installing-carbon Steps to install Carbon on a Windows dedicated Rust server. ```bash 1. Go to the GitHub Releases page and download the latest `Carbon.Windows.TARGET.zip`. 2. Unpack the archive in the root folder of your server; extract all files the same way they're presented in the archive, on top of the folder where `RustDedicated.exe` exists. 3. Launch the server as you normally would, with your shell/batch command line instructions. 4. **You're good to go!** ``` -------------------------------- ### Carbon Plugin Example Source: https://carbonmod.gg/devs/creating-your-first-plugin An example of a Carbon-only plugin that extends Oxide functionality. ```csharp namespace Carbon.Plugins; [Info("MyPlugin", "", "1.0.0")] [Description("")] public class MyPlugin : CarbonPlugin { private void OnServerInitialized() { Puts("Hello world!"); } } ``` -------------------------------- ### Lang File Example Source: https://carbonmod.gg/tutorials/beginners-guide/localization An example of a JSON lang file used for localization, demonstrating string replacement with placeholders like {0}. ```json { "cooldown_player": "You're cooled down. Please wait {0}.", "unknown_chat_cmd_1": "Unknown command: {0}", "unknown_chat_cmd_2": "Unknown command: {0}\nSuggesting: {1}", "unknown_chat_cmd_separator_1": ", ", "unknown_chat_cmd_separator_2": " or ", "no_perm": "You don't have any of the required permissions to run this command.", "no_group": "You aren't in any of the required groups to run this command.", "no_auth": "You don't have the minimum auth level [{0}] required to execute this command [your level: {1}]." } ``` -------------------------------- ### Manual Patching Example Source: https://carbonmod.gg/devs/creating-hooks An example demonstrating how to manually manage Harmony patches in Carbon. ```csharp using System; using HarmonyLib; namespace Carbon.Plugins; [Info("Collaborate", "Carbon Community", "1.0.0")] public class Collaborate : CarbonPlugin { public Harmony _PATCH; public const string DOMAIN = "com.carbon.mypatch"; private void Init() { _PATCH = new Harmony(DOMAIN); _PATCH.PatchAll(Assembly.GetExecutingAssembly()); Puts("Patched."); } private void Unload() { _PATCH.UnpatchAll(DOMAIN); Puts("Unpatched."); } #region Patches [HarmonyPatch(typeof(BasePlayer), "CanSuicide", new Type[] { })] public class Patch_1 { public static bool Prefix(BasePlayer __instance, ref bool __result) { Logger.Log("Works!"); __result = false; // Returning false will prohibit the original code from executing // Only applies to Prefixes return false; } } #endregion } ``` -------------------------------- ### Example Plugin Usage Source: https://carbonmod.gg/devs/modules/date-picker-module An example of how to use the DatePickerModule in a plugin to get and process a player's selected date. ```csharp datePicker.Open(player, (date) { Puts($"Player picked date {date.ToShortDateString()}"); // Use the selected date in plugin logic }); ``` -------------------------------- ### Example Use in Plugin Source: https://carbonmod.gg/devs/modules/image-db-module A concise example showing queuing an image and retrieving its ID. ```csharp imageDb.Queue("logo", "https://mydomain.com/logo.png"); var id = imageDb.GetImage("logo"); ``` -------------------------------- ### Editing CarbonAuto Config Examples Source: https://carbonmod.gg/owners/features/carbonauto Examples of how to edit CarbonAuto configuration through commands. ```text c.custommapname "My Awesome Map" ``` -------------------------------- ### OnConsoleCommand Example Source: https://carbonmod.gg/references/hooks?s=OnConsoleCommand Example of how to use the OnConsoleCommand hook. ```csharp using Facepunch.Console; public class MyPlugin : CovalencePlugin { // Called when a console command is executed on the server. object OnConsoleCommand(ConsoleSystem.Arg arg) { Puts($"Console command executed: {arg.cmd}"); return null; // No return behavior } } ``` -------------------------------- ### Example of Setting Steam Icon Source: https://carbonmod.gg/devs/features/lightweight-ui Example demonstrating how to set a Steam avatar using an empty container. ```csharp // Example cui.v2.CreateEmptyContainer(mainPanel, add: true).SetOffset(new LuiOffset(0, 0, 256, 256)).SetSteamIcon(564345673); ``` -------------------------------- ### OnLoaded [Instance] Source: https://carbonmod.gg/references/hooks?s=OnLoaded+%5BInstance%5D Called after the plugin finishes loading; use this to run post-load setup. Great place to start timers or cache references after load. ```C# using Carbon.Common; using Carbon.Core.ModLoader; // PluginOxide Compatible public class MyPlugin { // Called after the plugin finishes loading public void OnLoaded() { // Your post-load setup code here Console.WriteLine("Plugin loaded successfully!"); } } ``` -------------------------------- ### OnLoaded [Instance] Source: https://carbonmod.gg/references/hooks?s=Loaded+%5BInstance%5D Called after the plugin finishes loading; use this to run post-load setup. Great place to start timers or cache references after load. ```C# using Carbon.Common; using Carbon.Core.ModLoader; // Called after the plugin finishes loading; use this to run post-load setup. // Great place to start timers or cache references after load. // No return behavior. ``` -------------------------------- ### AutoWipe Configuration Example Source: https://carbonmod.gg/owners/modules/optional-modules/autowipe-module Example configuration for the AutoWipe module, showing settings for wipe commands, post-wipe actions, map pools, and scheduled wipes. ```json { "WipeChatCommand": "nextwipe", "FullWipe": { "PostWipeCommands": [ "c.reload MyPlugin" ], "PostWipeDeletes": [ "carbon/data/myfile.json" ] }, "MapWipe": { "PostWipeCommands": [], "PostWipeDeletes": [] }, "Maps": [ { "Url": "https://example.com/my-map.map", "Temp": false } ], "AvailableWipes": [ { "WipeName": "Biweekly Full Wipe", "MapBrowserName": "MyMap", "MapUrl": "POOL", "MapSize": 4000, "ServerSeed": 12345, "Cron": "0 18 */14 * *", "Temp": false, "Type (0=fullwipe 1=mapwipe)": 0, "Commands": [ "say Full wipe incoming!", "server.save" ] } ] } ``` -------------------------------- ### Example Use Case Configuration Source: https://carbonmod.gg/owners/modules/optional-modules/stack-manager-module An example configuration demonstrating how to triple food stacks and set specific stack caps for scrap and refined metal. ```json { "Categories": { "Food": 3.0 }, "Items": { "scrap": 5000, "metal.refined": 1000 } } ``` -------------------------------- ### Config File Example Source: https://carbonmod.gg/devs/features/vault Example of how config properties look when using the vault. ```json { "Username": null, "Password": "{global:pwd}" } ``` -------------------------------- ### Example Use in Plugin Source: https://carbonmod.gg/devs/modules/color-picker-module A practical example of using the color picker in a plugin to display the picked color and alpha value. ```csharp colorPicker.Open(player, (hex, raw, alpha) => { Puts($"Player picked color {hex} with alpha {alpha}"); // Apply to UI or save preference }); ``` -------------------------------- ### Admin Extensions Module Configuration Example Source: https://carbonmod.gg/news/carbon/sql-permissions Example configuration for the AdminExtensions module, showing commands and their required permissions. ```json { "Analytics": { "Enabled": true }, "SelfUpdating": { "Enabled": false, "HookUpdates": true, "RedirectUri": "https://my.endpoint/carbon.tar.gz" }, "Debugging": { "ScriptDebuggingOrigin": "", "HookLagSpikeThreshold": 1000 } } ``` -------------------------------- ### Universal Command Example Source: https://carbonmod.gg/devs/features/commands Accessible through all interfaces (chat, F1, console, RCon). ```csharp [Command("myunicommand")] private void MyUniversalCommand(BasePlayer player, string command, string[] args) { if (player == null) { Puts("woo Wee!"); } else { player.ChatMessage("Wee woo!"); } } ``` -------------------------------- ### Console Command Example Source: https://carbonmod.gg/devs/features/commands Available in F1 console and server terminal or RCon. ```csharp [ConsoleCommand("mycommand2")] private void MyCommand2(ConsoleSystem.Arg arg) { arg.ReplyWith("Just got called!"); } ``` -------------------------------- ### Bridge Server Start Source: https://carbonmod.gg/devs/features/bridge This code snippet shows how to start the Bridge server with optional IP and port, and a required password. The Bridge server will not boot unless the password is set in the command-line. ```csharp Carbon.Components.Bridge.Server.Start( port: Carbon.Switches.GetBridgePort(defaultValue: $"{RCon.Port + 1}").ToInt(), password: Carbon.Switches.GetBridgePassword(defaultValue: "unset"), ip: Carbon.Switches.GetBridgeIp()); ``` -------------------------------- ### Multiple Authentication Levels Example Source: https://carbonmod.gg/devs/features/commands You may use one (like above) or multiple authentication levels. ```csharp // Players must have the 'plugin.use' permission, // have assigned owner AuthLevel and will only allow // the command to be called every 10 seconds by the same player. [ChatCommand("helloworld"), Permission("plugin.use"), AuthLevel(2), Cooldown(10_000)] private void HelloWorld(BasePlayer player, string command, string[] args) { } ``` -------------------------------- ### Framework Conditional Source: https://carbonmod.gg/devs/features/conditionals Example demonstrating how to use the CARBON preprocessor directive to differentiate between Carbon and Oxide environments. ```csharp private void OnServerInitialized() { #if CARBON Puts("This is called on Carbon."); #endif #if !CARBON Puts("This is called on Oxide."); #endif } ``` -------------------------------- ### Command Registration with Permissions Source: https://carbonmod.gg/tutorials/beginners-guide/localization This comprehensive example shows how to register a chat command, register a permission, and implement permission checks within the command handler. ```csharp using System.Collections.Generic; public const string PermUse = "HelloThere.use"; protected override void LoadDefaultMessages() { lang.RegisterMessages(new Dictionary { ["Hello"] = "Hello there!", ["NoPerm"] = "You do not have permission to use this command.", }, this, "en"); } private void Init() { cmd.AddChatCommand("hi", this, nameof(CmdHello)); permission.RegisterPermission(PermUse, this); } private void LangMessage(BasePlayer player, string key) { player.ChatMessage(lang.GetMessage(key, this, player.UserIDString)); } private void CmdHello(BasePlayer player, string command, string[] args) { if(!permission.UserHasPermission(player.UserIDString, PermUse)) { LangMessage(player, "NoPerm"); return; } LangMessage(player, "Hello"); } ``` -------------------------------- ### Localization Example Source: https://carbonmod.gg/tutorials/beginners-guide/localization This C# code demonstrates how to register messages in multiple languages and use string formatting to personalize greetings. ```csharp using System.Collections.Generic; public const string PermUse = "HelloThere.use"; protected override void LoadDefaultMessages() { lang.RegisterMessages(new Dictionary { ["Hello"] = "Hello there!", ["NoPerm"] = "You do not have permission to use this command.", ["Welcome"] = "Welcome to the server, {0}!", }, this, "en"); } private void Init() { cmd.AddChatCommand("hi", this, nameof(CmdHello)); permission.RegisterPermission(PermUse, this); } private void LangMessage(BasePlayer player, string key) { player.ChatMessage(lang.GetMessage(key, this, player.UserIDString)); } private void LangMessage(BasePlayer player, string key, params string[] args) { player.ChatMessage(string.Format(lang.GetMessage(key, this, player.UserIDString),args)); } private void CmdHello(BasePlayer player, string command, string[] args) { if(!permission.UserHasPermission(player.UserIDString, PermUse)) { LangMessage(player, "NoPerm"); return; } LangMessage(player, "Hello"); LangMessage(player,"Welcome", player.displayName); } ``` -------------------------------- ### Full Config Management Example Source: https://carbonmod.gg/tutorials/beginners-guide/config-management This C# code demonstrates a complete configuration management system for a Rust plugin using CarbonMod, including versioning, JSON serialization, default loading, and updating. ```csharp using Newtonsoft.Json; using Oxide.Core; namespace Oxide.Plugins; [Info("CoolPlugin", "Bubbafett", "1.0.1")] [Description("Cool plugin that tells players about cool permissions.")] public class ConfigExample : RustPlugin { #region Config public Configuration PluginConfig; public class Configuration { [JsonProperty(PropertyName = "Version (DO NOT CHANGE)", Order = int.MaxValue)] public VersionNumber Version = new(1, 0, 1); [JsonProperty(PropertyName = "Permission")] public string UsePermission = "CoolPlugin.use"; [JsonProperty(PropertyName = "Permission Enabled")] public bool IsEnabled = true; } protected override void LoadDefaultConfig() => PluginConfig = new Configuration(); protected override void SaveConfig() => Config.WriteObject(PluginConfig, true); protected override void LoadConfig() { base.LoadConfig(); PluginConfig = Config.ReadObject(); if (PluginConfig == null) { PluginConfig = new Configuration(); SaveConfig(); return; } UpdateConfig(); } private void UpdateConfig() { if (PluginConfig.Version >= Version) return; PrintWarning("Outdated configuration file detected. Updating..."); PluginConfig.IsEnabled = true; PluginConfig.Version = Version; SaveConfig(); } #endregion #region Hooks private void Init() { permission.RegisterPermission(PluginConfig.UsePermission, this); } private void OnPlayerConnected(BasePlayer player) { if (!PluginConfig.IsEnabled) return; if(permission.UserHasPermission(player.UserIDString,PluginConfig.UsePermission)) { server.Broadcast("Someone has connected with the Cool Plugin features enabled!"); } else { server.Broadcast("Someone has connected without the Cool Plugin features enabled."); } } #endregion } ``` -------------------------------- ### Config Class Example Source: https://carbonmod.gg/devs/features/vault Example of a C# config class utilizing the Vault.Protected JsonConverter. ```csharp public class ConfigTest { public string Username; #if CARBON [JsonConverter(typeof(Vault.Protected))] #endif public string Password; } ``` -------------------------------- ### Giving Player an Item Source: https://carbonmod.gg/tutorials/beginners-guide/first-plugin This code snippet demonstrates how to give a player an item ('rock') when they wake up, using ItemManager.CreateByName and Player.GiveItem. It also shows how to send a chat message to the player. ```csharp namespace Carbon.Plugins; [Info("MyFirstPlugin", "Bubbafett", "1.0.0")] [Description("A Simple plugin that prints a message when loaded.")] public class MyFirstPlugin : CarbonPlugin { private string _message = "Do a flip!"; private void Loaded() { Puts(_message); } private void OnPlayerSleepEnded(BasePlayer basePlayer) { Item rock = ItemManager.CreateByName("rock"); Player.GiveItem(basePlayer, rock); basePlayer.ChatMessage($"You have been given a {rock.info.displayName.english} for waking up!"); } } ``` -------------------------------- ### Vault Commands Example Source: https://carbonmod.gg/devs/features/vault Examples of using the built-in RCon commands for vault management. ```csharp > c.vault factory items encrypted value plain test1 False aaa passwords test2 True global pwd True > c.find vault command value help c.vault Prints a whole list of all vault factory and item keys without any protected values c.vault_add Adds a new element to the vault c.vault_remove Removes an element from the vault > c.vault_add Syntax: c.vault_add [encrypted|true] [factory|global] ``` -------------------------------- ### Install LinuxGSM Source: https://carbonmod.gg/owners/linux-gsm This command installs LinuxGSM. You will be prompted to select 'rustcarbon' from a list of available mods. ```bash ./rustserver mods-install ``` -------------------------------- ### Text Customization Examples Source: https://carbonmod.gg/devs/features/lightweight-ui Demonstrates two ways to customize text elements: a one-line method for immediate changes and a multi-line method for more complex or chained updates. ```csharp // One-line method. cui.v2.CreateText(...).SetTextFont(CUI.Handler.FontTypes.RobotoCondensedRegular); // Multi-line method. LUI.LuiContainer text = cui.v2.CreateText(...); text.SetTextFont(CUI.Handler.FontTypes.RobotoCondensedRegular); ``` -------------------------------- ### Basic Plugin Structure Source: https://carbonmod.gg/tutorials/beginners-guide/first-plugin This code snippet shows the basic structure of a Carbon plugin, including the necessary attributes and a simple hook for when the plugin loads and when a player wakes up. ```csharp namespace Carbon.Plugins; [Info("MyFirstPlugin", "Bubbafett", "1.0.0")] [Description("A Simple plugin that prints a message when loaded.")] public class MyFirstPlugin : CarbonPlugin { private string _message = "Do a flip!"; private void Loaded() { Puts(_message); } private void OnPlayerSleepEnded(BasePlayer basePlayer) { Puts("OnPlayerSleepEnded has been called!"); } } ``` -------------------------------- ### Plugin with Message Output Source: https://carbonmod.gg/tutorials/beginners-guide/first-plugin Implements the 'Loaded' hook to print a predefined message to the console when the plugin is loaded, using the Puts() method and a private field to store the message. ```csharp namespace Carbon.Plugins; [Info("MyFirstPlugin", "Bubbafett", "1.0.0")] [Description("A Simple plugin that prints a message when loaded.")] public class MyFirstPlugin : CarbonPlugin { private string _message = "Do a flip!"; private void Loaded() { Puts(_message); } } ``` -------------------------------- ### Loaded [Instance] Source: https://carbonmod.gg/references/hooks?s=Loaded+%5BInstance%5D Called after the plugin has been loaded and its dependencies are ready. All dependencies are available at this point; perform post-load setup. ```C# using Carbon.Common; using Carbon.Core.ModLoader; // Called after the plugin has been loaded and its dependencies are ready. // All dependencies are available at this point; perform post-load setup. // No return behavior. ``` -------------------------------- ### Initializing CuiHandler Source: https://carbonmod.gg/devs/features/lightweight-ui Example of how to initialize the CuiHandler, which is an instance of Carbon's CUI system. ```csharp // `CuiHandler` is an instance of Carbon's CUI system using CUI cui = new CUI(CuiHandler); ``` -------------------------------- ### Implementation Example Source: https://carbonmod.gg/devs/features/async-shutdown An example of overriding OnAsyncServerShutdown to delay shutdown for critical tasks, simulating a 3-second cleanup and waiting for a web request. ```csharp public override async ValueTask OnAsyncServerShutdown() { // Simulate a 3-second cleanup task. await AsyncEx.WaitForSeconds(3f); // Wait for a full web request call await webrequest.EnqueueAsync( "https://google.com", null, (code, data) => { if (code != 200) return; // Handle errors // Process response data }, this ); } ``` -------------------------------- ### Creating Panel Aliases Source: https://carbonmod.gg/devs/features/lightweight-ui Illustrates the multiple aliases available for creating UI elements, showing how parameters can be omitted when not needed (e.g., position when it's None). ```csharp CreatePanel(string parent, LuiPosition position, LuiOffset offset, ...); // Base CreatePanel(string parent, LuiOffset offset, ...); // When position is None, we don't need to include it in method. CreatePanel(LuiContainer container, LuiPosition position, LuiOffset offset, ...); // Same as first, but we can just put the element we created previously without name knowledge. CreatePanel(LuiContainer container, LuiOffset offset, ...); // Same as second, but we can just put the element we created previously without name knowledge. ``` -------------------------------- ### Example Use in Plugin Source: https://carbonmod.gg/devs/modules/file-picker-module A practical example of using the File Module to open a file browser for JSON files. ```csharp fileModule.Open(player, "Browse JSON Files", "/carbon/data", "/carbon/data", "json", onConfirm: (player, browser) => { Puts($"Confirmed: {browser.SelectedFile}"); }, onCancel: (player, browser) => { Puts("Cancelled."); }); ``` -------------------------------- ### Hook Attribute Patch Example Source: https://carbonmod.gg/devs/creating-hooks Example of the HookAttribute used for patching, specifying the hook name, type, method, and parameters. ```csharp [HookAttribute.Patch("OnHookName", "OnHookName [main]", typeof(Type), "Method", [/* Method params */])] ``` -------------------------------- ### Example Use in Plugin: Preferences Modal Source: https://carbonmod.gg/devs/modules/modal-module An example of using the ModalModule to create a preferences modal with HexColor and Boolean fields. ```csharp var fields = new Dictionary { ["favorite_color"] = ModalModule.Modal.Field.Make("Favorite Color", ModalModule.Modal.Field.FieldTypes.HexColor), ["notifications"] = ModalModule.Modal.Field.Make("Enable Notifications", ModalModule.Modal.Field.FieldTypes.Boolean, @default: true) }; modalModule.Open(player, "Preferences", fields, onConfirm: (player, modal) => { var color = modal.Get("favorite_color"); var enabled = modal.Get("notifications"); Puts($"{player.displayName}'s prefs - Color: {color}, Notifications: {enabled}"); }); ``` -------------------------------- ### Plugin Class with Metadata Source: https://carbonmod.gg/tutorials/beginners-guide/first-plugin Defines the main plugin class, inheriting from CarbonPlugin, and includes metadata such as the plugin's name, author, version, and description. ```csharp namespace Carbon.Plugins; [Info("MyFirstPlugin", "Bubbafett", "1.0.0")] [Description("A simple plugin that prints a message when loaded.")] public class MyFirstPlugin : CarbonPlugin { } ``` -------------------------------- ### Sending UI to a Player Source: https://carbonmod.gg/devs/features/lightweight-ui Demonstrates how to send the built UI to a player, with options for sending as bytes (more efficient) or as JSON (for debugging/testing). ```csharp // Sends built UI to player cui.v2.SendUi(player); // Sends JSON variant of UI // (optional debug/test alternative, sending UI in bytes is more efficient) cui.v2.SendUiJson(player); ``` -------------------------------- ### Collaborate Plugin Example with AutoPatch Source: https://carbonmod.gg/devs/creating-hooks A complete example of a CarbonPlugin named 'Collaborate' that uses the [AutoPatch] attribute to patch the 'CanSuicide' method of the BasePlayer class. ```csharp using System; using HarmonyLib; using Oxide.Core.Plugins; namespace Carbon.Plugins; [Info("Collaborate", "Carbon Community", "1.0.0")] public class Collaborate : CarbonPlugin { #region Patches [AutoPatch] [HarmonyPatch(typeof(BasePlayer), "CanSuicide", new Type[] { })] public class Patch_1 { public static bool Prefix(BasePlayer __instance, ref bool __result) { Logger.Log("Works!"); __result = false; return false; } } #endregion } ``` -------------------------------- ### Accessing the DatePickerModule Source: https://carbonmod.gg/devs/modules/date-picker-module How to get an instance of the DatePickerModule in a plugin. ```csharp var datePicker = Carbon.Base.BaseModule.GetModule(); ``` -------------------------------- ### Getting All Groups Source: https://carbonmod.gg/devs/features/permissions Retrieves all available groups on the server. ```csharp var groups = permission.GetGroups(); ``` -------------------------------- ### Handling Player Connections and Permissions Source: https://carbonmod.gg/tutorials/beginners-guide/config-management This code snippet demonstrates listening to the OnPlayerConnected() hook, checking for required permissions, and broadcasting messages accordingly. ```csharp #region Hooks private void Init() { permission.RegisterPermission(PluginConfig.UsePermission, this); } private void OnPlayerConnected(BasePlayer player) { if (permission.UserHasPermission(player.UserIDString, PluginConfig.UsePermission)) { server.Broadcast("Someone has connected with the Cool Plugin features enabled!"); } else { server.Broadcast("Someone has connected without the Cool Plugin features enabled."); } } #endregion ``` -------------------------------- ### Helper Methods for Images Source: https://carbonmod.gg/devs/features/lightweight-ui List of helper methods for customizing image elements. ```csharp .SetColor(string color); .SetMaterial(string material); .SetImageType(UnityEngine.UI.Image.Type imageType); .SetSprite(string sprite = null, string color = null, UnityEngine.UI.Image.Type imageType = Image.Type.Simple); .SetImage(string png = null, string color = null); .SetItemIcon(int itemid, ulong skinid); ```