### Example permissions.yml Configuration Source: https://github.com/michal78900/projectmer/wiki/Permissions This YAML configuration demonstrates how to set permissions for user roles or groups within the Project Mer plugin. It shows how to grant access to all MER commands for the 'owner' role by including 'mpr.*' in the permissions list. ```yaml default: inherited_groups: [] permissions: [] owner: inherited_groups: [] permissions: - mpr.* ``` -------------------------------- ### Configuring Plugin Behavior in C# Source: https://context7.com/michal78900/projectmer/llms.txt This C# snippet shows how to access and modify ProjectMER plugin configuration settings. It covers enabling hot-reloading, auto-selection of objects, and defining actions to be triggered on specific game events like round start or warhead detonation. Requires the ProjectMER.Configs namespace. ```csharp using ProjectMER.Configs; // Access configuration Config config = ProjectMER.Singleton.Config; // Enable hot-reloading of map files config.EnableFileSystemWatcher = true; // Auto-select spawned objects config.AutoSelect = true; // Configure actions on game events config.OnRoundStarted = new List { "load:DefaultMap", "console:/bc 10 Map loaded!" }; config.OnWaitingForPlayers = new List { "unload:*", "load:LobbyMap" }; config.OnWarheadDetonated = new List { "load:PostNukeMap||PostNukeVariant2||PostNukeVariant3", "console:gamerule respawn_time 15" }; // Load random map variant config.OnRoundStarted = new List { "load:MapA||MapA||MapB||MapC" // 50% chance MapA, 25% each for B and C }; ``` -------------------------------- ### Object Spawning Console Commands Source: https://context7.com/michal78900/projectmer/llms.txt Bash commands for spawning various objects in the game world using ProjectMER. Objects can be created at the player's look position or at specific coordinates, and aliases are available for common commands. ```bash # Create object at look position mp create Light mp create Primitive mp create CustomSchematic # Create at specific coordinates mp create Light 10.5 5.0 15.2 mp create Primitive 0 2 0 # Create with aliases mp cr Workstation mp spawn ItemSpawnpoint ``` -------------------------------- ### Registering Schematic Event Handlers in C# Source: https://context7.com/michal78900/projectmer/llms.txt This C# code demonstrates how to hook into various schematic lifecycle events provided by ProjectMER. It allows custom logic execution during schematic spawning, post-spawning, button interactions, and destruction. Ensure ProjectMER.Events and ProjectMER.Events.Arguments namespaces are available. ```csharp using ProjectMER.Events.Handlers; using ProjectMER.Events.Arguments; public class MyEventHandler { public void RegisterEvents() { Schematic.SchematicSpawning += OnSchematicSpawning; Schematic.SchematicSpawned += OnSchematicSpawned; Schematic.ButtonInteracted += OnButtonInteracted; Schematic.SchematicDestroyed += OnSchematicDestroyed; } private void OnSchematicSpawning(SchematicSpawningEventArgs ev) { Logger.Info($"Spawning schematic: {ev.Name}"); // Cancel spawn conditionally if (ev.Name == "DisabledSchematic") { ev.IsAllowed = false; Logger.Warn("Schematic spawn cancelled"); } // Modify data before spawn ev.Data.Blocks[0].Position += Vector3.up; } private void OnSchematicSpawned(SchematicSpawnedEventArgs ev) { Logger.Info($"Schematic spawned: {ev.Schematic.Id}"); Logger.Info($"Position: {ev.Schematic.AttachedObject.transform.position}"); } private void OnButtonInteracted(ButtonInteractedEventArgs ev) { Logger.Info($"Player {ev.Player.Nickname} pressed button on {ev.Schematic.Id}"); } private void OnSchematicDestroyed(SchematicDestroyedEventArgs ev) { Logger.Info($"Schematic destroyed: {ev.Schematic.Id}"); } } ``` -------------------------------- ### Create Objects with ToolGun Source: https://context7.com/michal78900/projectmer/llms.txt Spawns various types of objects programmatically, similar to the in-game ToolGun functionality. Objects can be spawned at the player's look position or at specified world coordinates. This allows for dynamic object generation based on game logic or player actions. ```csharp using ProjectMER.Features.ToolGun; using ProjectMER.Features.Enums; using LabApi.Features.Wrappers; using UnityEngine; // Spawn object at player's look position Player player = Player.Get("PlayerName"); ToolGunHandler.CreateObject(player, ToolGunObjectType.Light); // Spawn at specific position ToolGunHandler.CreateObject( new Vector3(15, 2, 10), ToolGunObjectType.ItemSpawnpoint ); // Spawn custom schematic ToolGunHandler.CreateObject( new Vector3(0, 0, 0), ToolGunObjectType.Schematic, "MyCustomSchematic" ); // Available object types: Primitive, Light, Door, Workstation, ItemSpawnpoint, // PlayerSpawnpoint, Capybara, Text, Interactable, Scp079Camera, ShootingTarget, // Schematic, Teleport, Locker, Waypoint ``` -------------------------------- ### Spawn Schematic Objects Source: https://context7.com/michal78900/projectmer/llms.txt Loads and spawns custom prefab collections defined in JSON format. Supports spawning by name, position, rotation, and scale, with safe spawning options and error handling. This functionality is crucial for dynamically populating game worlds with pre-defined structures. ```csharp using ProjectMER.Features; using ProjectMER.Features.Objects; using UnityEngine; // Spawn by name and position SchematicObject schematic = ObjectSpawner.SpawnSchematic( "CustomRoom", new Vector3(10, 0, 10) ); // Spawn with rotation SchematicObject rotatedSchematic = ObjectSpawner.SpawnSchematic( "CustomRoom", new Vector3(20, 0, 20), Quaternion.Euler(0, 90, 0) ); // Spawn with full transform SchematicObject scaledSchematic = ObjectSpawner.SpawnSchematic( "CustomRoom", new Vector3(30, 0, 30), Vector3.zero, new Vector3(1.5f, 1.5f, 1.5f) ); // Safe spawning with error handling if (ObjectSpawner.TrySpawnSchematic("CustomRoom", Vector3.zero, out SchematicObject obj)) { Logger.Info($"Schematic spawned with ID: {obj.Id}"); } else { Logger.Error("Failed to spawn schematic"); } // Console command // mp create CustomRoom 15 0 20 ``` -------------------------------- ### Load Schematic Data Source: https://context7.com/michal78900/projectmer/llms.txt Retrieves schematic definitions from the file system, allowing for programmatic access to schematic data such as block types, positions, and metadata. This is essential for loading, inspecting, or spawning schematics dynamically. Includes safe loading with exception handling for missing files or directories. ```csharp using ProjectMER.Features; using ProjectMER.Features.Serializable.Schematics; // Load schematic data safely if (MapUtils.TryGetSchematicDataByName("CustomStructure", out SchematicObjectDataList data)) { Logger.Info($"Schematic path: {data.Path}"); Logger.Info($"Block count: {data.Blocks.Count}"); foreach (var block in data.Blocks) { Logger.Info($"Block at {block.Position}: {block.Name}"); } } // Load with exception handling try { SchematicObjectDataList data = MapUtils.GetSchematicDataByName("CustomStructure"); Logger.Info($"Loaded schematic from: {data.Path}"); } catch (DirectoryNotFoundException ex) { Logger.Error($"Schematic directory missing: {ex.Message}"); } catch (FileNotFoundException ex) { Logger.Error($"Schematic JSON missing: {ex.Message}"); } // Get all available schematics string[] schematics = MapUtils.GetAvailableSchematicNames(); Logger.Info($"Available schematics: {string.Join(", ", schematics)}"); ``` -------------------------------- ### Map Management Console Commands Source: https://context7.com/michal78900/projectmer/llms.txt A set of bash commands for managing maps within the ProjectMER environment. These commands allow loading, saving, unloading, listing, and merging maps directly from the console. Aliases are provided for brevity. ```bash # Load a map mp load CustomLCZ mp l CustomLCZ # Save current edits mp save CustomLCZ mp s CustomLCZ # Unload a map mp unload CustomLCZ # List available maps and schematics mp list # Merge maps mp merge SourceMap DestinationMap ``` -------------------------------- ### Spawn Primitive Object in C# - ProjectMER Source: https://context7.com/michal78900/projectmer/llms.txt Spawns basic geometric shapes like cubes, spheres, and planes with configurable properties such as position, rotation, scale, color, and collision flags. It utilizes the ObjectSpawner class and SerializablePrimitive structure. A console command for spawning is also provided. ```csharp using ProjectMER.Features; using UnityEngine; using AdminToys; // Spawn a primitive using ObjectSpawner PrimitiveObjectToy cube = ObjectSpawner.SpawnPrimitive(new SerializablePrimitive { PrimitiveType = PrimitiveType.Cube, Position = new Vector3(0, 5, 0), Rotation = Vector3.zero, Scale = new Vector3(2, 2, 2), Color = "#FF0000", PrimitiveFlags = PrimitiveFlags.Visible | PrimitiveFlags.Collidable, Room = "Outside", Index = -1 }); Logger.Info($"Spawned cube at {cube.transform.position}"); // Spawn via console command // mp create Primitive 10.5 5.0 15.2 ``` -------------------------------- ### Access Map Data in C# - ProjectMER Source: https://context7.com/michal78900/projectmer/llms.txt Retrieves map configuration data without loading it into the game. It provides a safe method with exception handling for file not found and demonstrates accessing counts for primitives, lights, and schematics within the MapSchematic object. ```csharp using ProjectMER.Features; using ProjectMER.Features.Serializable; // Get map data safely if (MapUtils.TryGetMapData("CustomHCZ", out MapSchematic map)) { Logger.Info($"Map has {map.Primitives.Count} primitives"); Logger.Info($"Map has {map.Lights.Count} lights"); Logger.Info($"Map has {map.Schematics.Count} schematics"); } // Or with exception handling try { MapSchematic map = MapUtils.GetMapData("CustomHCZ"); foreach (var primitive in map.Primitives) { Logger.Info($"Primitive {primitive.Key}: {primitive.Value.PrimitiveType}"); } } catch (FileNotFoundException) { Logger.Error("Map file does not exist"); } ``` -------------------------------- ### Utility Console Commands Source: https://context7.com/michal78900/projectmer/llms.txt Miscellaneous bash commands for ProjectMER utility functions. These include toggling the ToolGun mode and controlling the visibility of object indicators. ```bash # Toggle ToolGun mode mp toggletoolgun mp tg # Show/hide object indicators mp indicators ``` -------------------------------- ### Load Map in C# - ProjectMER Source: https://context7.com/michal78900/projectmer/llms.txt Loads a map from disk by its name. Handles File and YAML parsing exceptions. It can also check for map data before attempting to load, providing the object count upon successful loading. ```csharp using ProjectMER.Features; // Load a map by name try { MapUtils.LoadMap("CustomLCZ"); Logger.Info("Map loaded successfully"); } catch (FileNotFoundException ex) { Logger.Error($"Map file not found: {ex.Message}"); } catch (YamlException ex) { Logger.Error($"YAML parsing error: {ex.Message}"); } // Check if map exists before loading if (MapUtils.TryGetMapData("CustomLCZ", out MapSchematic mapData)) { MapUtils.LoadMap("CustomLCZ"); Logger.Info($"Loaded map with {mapData.SpawnedObjects.Count} objects"); } ``` -------------------------------- ### Object Modification Console Commands Source: https://context7.com/michal78900/projectmer/llms.txt A collection of bash commands for editing properties of selected objects in ProjectMER. This includes deleting, moving (setting, adding, grabbing, bringing), rotating, and scaling objects with various options. ```bash # Select object mp select # Delete selected object mp delete # Modify position mp modify position set 10 5 15 mp modify position add 0 2 0 mp modify position grab # Move to player position mp modify position bring # Move to look position # Modify rotation mp modify rotation set 0 90 0 mp modify rotation add 0 45 0 # Modify scale mp modify scale set 2 2 2 mp modify scale add 0.5 0.5 0.5 ``` -------------------------------- ### Select Map Objects Source: https://context7.com/michal78900/projectmer/llms.txt Enables targeting and selecting specific map objects for further manipulation. It allows finding objects by player's current view or by their unique ID. Once selected, these objects can be acted upon by other ToolGun functions, such as deletion or modification. ```csharp using ProjectMER.Features.ToolGun; using ProjectMER.Features.Objects; using LabApi.Features.Wrappers; Player player = Player.Get("PlayerName"); // Select object player is looking at if (ToolGunHandler.TryGetMapObject(player, out MapEditorObject targetObject)) { ToolGunHandler.SelectObject(player, targetObject); Logger.Info($"Selected object: {targetObject.Id}"); } // Get currently selected object if (ToolGunHandler.TryGetSelectedMapObject(player, out MapEditorObject selected)) { Logger.Info($"Current selection: {selected.AttachedObject.GetType().Name}"); Logger.Info($"Position: {selected.RelativePosition}"); } // Find object by ID across all loaded maps if (ToolGunHandler.TryGetObjectById("a1b2c3d4", out MapEditorObject obj)) { ToolGunHandler.SelectObject(player, obj); } // Console command // mp select ``` -------------------------------- ### Save Map in C# - ProjectMER Source: https://context7.com/michal78900/projectmer/llms.txt Saves the current map state to a YAML file. It can merge unsaved changes from the 'Untitled' map. Handles InvalidOperationException for reserved names. An equivalent console command is also noted. ```csharp using ProjectMER.Features; // Save current edits to a named map try { MapUtils.SaveMap("CustomLCZ"); Logger.Info("Map saved to LabAPI-beta/configs/ProjectMer/Maps/CustomLCZ.yml"); } catch (InvalidOperationException ex) { Logger.Error($"Cannot use reserved name: {ex.Message}"); } // Console command equivalent // mp save CustomLCZ ``` -------------------------------- ### Unload Map in C# - ProjectMER Source: https://context7.com/michal78900/projectmer/llms.txt Removes all objects of a loaded map from the game world and clears it from memory. Returns a boolean indicating success and logs the outcome. It also demonstrates iterating through currently loaded maps. ```csharp using ProjectMER.Features; // Unload a specific map bool unloaded = MapUtils.UnloadMap("CustomLCZ"); if (unloaded) { Logger.Info("Map unloaded and all objects destroyed"); } else { Logger.Warn("Map was not loaded"); } // Check loaded maps foreach (var kvp in MapUtils.LoadedMaps) { Logger.Info($"Loaded map: {kvp.Key} with {kvp.Value.SpawnedObjects.Count} objects"); } ``` -------------------------------- ### Delete Map Objects Source: https://context7.com/michal78900/projectmer/llms.txt Provides functionality to remove objects from the game map. Objects can be deleted if they are currently selected by the player or by directly looking at them. This operation permanently removes the object and its associated game data. ```csharp using ProjectMER.Features.ToolGun; using ProjectMER.Features.Objects; // Delete selected object if (ToolGunHandler.TryGetSelectedMapObject(player, out MapEditorObject selected)) { ToolGunHandler.DeleteObject(selected); Logger.Info("Object deleted from map"); } // Delete by lookup if (ToolGunHandler.TryGetMapObject(player, out MapEditorObject target)) { ToolGunHandler.DeleteObject(target); } // Console command // mp delete ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.