EXILED (EXtended In-runtime Library for External Development)

repository·master·Indexed 41 days ago

https://github.com/exmod-team/exiled

A low-level plugin framework for SCP: Secret Laboratory that provides an event-based system to manipulate game behavior without editing server Assemblies. It utilizes Harmony and IL transpilers to maintain resilience against game updates. The framework includes an automated installer (Exiled.Installer) for Windows and Linux, supporting custom AppData paths, target versions, and containerized environments like Pterodactyl.

Tokens
39.2K
Snippets
241
Records
263
Agent score
52%

What's inside EXILED

  1. What is EXILED?

    master

    EXILED (EXtended In-runtime Library for External Development) is a low-level plugin framework for SCP: Secret Laboratory (compatible with MP2).

    It provides an event-based system that allows developers to hook into game code to manipulate or change behavior without directly editing the server's Assemblies. It utilizes Harmony and IL transpilers to achieve this, which ensures that the framework remains resilient to small game updates and allows the source code to be freely shared and contributed to.

  2. How to use Event Arguments and the IsAllowed property

    master

    Most events provide an event argument class (found in the Exiled.Events.EventArgs namespace) that inherits from IExiledEvent. These arguments contain the data relevant to the event and, for many events, the ability to cancel the action.

    Denying Events

    If an event implements IDeniableEvent, you can use the IsAllowed property to control whether the event proceeds:

    • Default true: Set IsAllowed = false to prevent the event from occurring (e.g., preventing an SCP from being enraged).
    • Default false: Set IsAllowed = true to allow an event that would otherwise be blocked (e.g., allowing a player to interact with a door they normally couldn't).
  3. What are Events in EXILED?

    master

    Events are the mechanism used to inform plugins when specific actions occur within the game (e.g., a round ending, a player throwing an item, or an SCP being enraged). They allow you to execute custom code before, during, or after an occurrence.

    Events are organized into static handlers found in the Exiled.Events namespace. Each handler is categorized by game feature (e.g., Exiled.Events.Scp096 for SCP-096 related actions).

  4. Install EXILED on Linux automatically

    master

    To perform an automatic installation of EXILED on a Linux server, download the Exiled.Installer-Linux binary from the official releases page.

    1. Move the Exiled.Installer-Linux file into your server directory (the directory containing the LocalAdmin executable).
    2. Execute the installer using ./Exiled.Installer-Linux.

    If you are running in a containerized environment (like Pterodactyl) where the process runs as root, you must use the --appdata flag to force the correct AppData folder path.

    ./Exiled.Installer-Linux
  5. Setup MEC (More Effective Coroutines)

    master
    To use MEC in your EXILED plugin, you must add a reference to the Assembly-CSharp-firstpass DLL file in your project. Once referenced, you can access the MEC API by adding using MEC; to your C# files. MEC provides timed methods that allow for execution delays without interrupting or sleeping the main game thread, making it safe for Unity-based environments where traditional threading can cause server crashes.
    using MEC;
  6. Connect and disconnect events in a plugin

    master

    To respond to events, you must subscribe your custom methods to the event handlers using the += operator. It is critical to unsubscribe using the -= operator when the plugin is disabled to prevent memory leaks or unexpected behavior.

    Typically, you perform these operations within the plugin's OnEnabled and OnDisabled lifecycle methods.

    using Exiled.Events;
    using Exiled.Events.EventArgs;
    
    public class MyPlugin : Plugin
    {
        public override void OnEnabled()
        {
            // Connect the event to your method
            Scp096.Enraging += OnEnraging;
        }
    
        public override void OnDisabled()
        {
            // Disconnect the event to clean up
            Scp096.Enraging -= OnEnraging;
        }
    
        private void OnEnraging(EnragingEventArgs ev)
        {
            // ev contains the event data
            Log.Info(ev.Player.Nickname + " has just been enraged!");
        }
    }
  7. Manually install EXILED

    master

    To install EXILED manually, follow these steps:

    1. Download the release: Go to the official GitHub releases page and download the Exiled.tar.gz file.
    2. Extract the files: Use a tool like 7Zip or WinRar to extract the contents of the archive.
    3. Replace the server DLL: Move the extracted Assembly-CSharp.dll file into your server's managed folder: (Your Server Folder)/SCPSL_Data/Managed. Replace the existing file when prompted.
    4. Install the EXILED folder: Move the extracted EXILED folder to your system's configuration directory (see path details below).
    # Summary of file movements:
    1. Assembly-CSharp.dll -> (Your Server Folder)/SCPSL_Data/Managed
    2. EXILED/ -> %appdata%
  8. Create a basic EXILED plugin

    master

    To be loaded by the EXILED framework, every plugin must consist of a main class that inherits from Plugin<IConfig> (found in the Exiled.API.Features namespace). You must also define a configuration class that implements the IConfig interface (found in the Exiled.API.Interfaces namespace). The IConfig interface requires an IsEnabled property.

    namespace MyPluginNamespace
    {
        using Exiled.API.Features;
        using Exiled.API.Interfaces;
    
        public class Plugin : Plugin<Config>
        {
            // The plugin class
        }
    
        public class Config : IConfig
        {
            public bool IsEnabled { get; set; }
        }
    }