Zum Inhalt springen
Riot-Bits

Riot-Bits

  • Heim
  • Nachricht
  • Führer
  • Videoanleitungen
  • Klebenotizzettel
  • Missbrauch melden
  • Suchformular umschalten

Ungedreht – How to Create a Plugin

Veröffentlicht am 12/14/2022 Von Jdance Keine Kommentare zu Ungedreht – How to Create a Plugin
  • Titel: Ungedreht
  • Veröffentlichungsdatum:
  • Entwickler:
  • Herausgeber:
Information about Unturned is still incomplete. Bitte helfen Sie uns dabei, die Details des Spiels auszufüllen Kontaktformular.

A guide on creating your first plugin.

Information

You’ll probably need Visual Studio 2019 Community Edition. Alongside that, this guide doesn’t tell you how to first set up your project. Here is a video on how to do that (you can also instead watch the tutorial series made by that creator):

Creating Your First Plugin

Creating plugins for Unturned requires a general knowledge of C#. If you currently do not have any knowledge behind C#, please check out Microsoft’s introduction to the language.

All plugins normally begin with class that inherits the `RocketPlugin` class. Below is an example of how to properly implement this:

using Rocket.API;
using Rocket.Core.Plugins;

namespace ExamplePlugin
{
public class ExamplePlugin : RocketPlugin
{

}
}

Notice how the `ExamplePlugin` class is public? This is so we can make it accessible to RocketMod.

Weiter geht's, you can now override the `Load` and `Unload` methods contained within the `RocketPlugin` class to log the loading and unloading of your plugin:

using Rocket.API;
using Rocket.Core.Plugins;
using Rocket.Unturned;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Player;
using Rocket.Core.Logging;

namespace ExamplePlugin
{
public class ExamplePlugin : RocketPlugin
{
protected override void Load()
{
Logger.Log("Example plugin loaded!");
}

protected override void Unload()
{
Logger.Log("Example plugin unloaded!");
}
}
}

The plugin will now log in the server console that the plugin has been loaded and unloaded.

You can also subscribe and unsubscribe to events when the plugin loads and unloads:

using Rocket.API;
using Rocket.Core.Plugins;
using Rocket.Unturned;
using Rocket.Core.Logging;

namespace ExamplePlugin
{
public class ExamplePlugin : RocketPlugin
{
protected override void Load()
{
Logger.Log("Example plugin loaded!");

U.Events.OnPlayerConnected += OnPlayerConnected;
}

protected override void Unload()
{
Logger.Log("Example plugin unloaded!");

U.Events.OnPlayerConnected -= OnPlayerConnected;
}

public void OnPlayerConnected(UnturnedPlayer player)
{
}
}
}

The plugin now subscribes and unsubscribes to the `U.Events.OnPlayerConnected`event on load and unload.

You can also now greet the player when they connect to the server:

using Rocket.API;
using Rocket.Core.Plugins;
using Rocket.Unturned;
using Rocket.Core.Logging;

namespace ExamplePlugin
{
public class ExamplePlugin : RocketPlugin
{
protected override void Load()
{
Logger.Log("Example plugin loaded!");

U.Events.OnPlayerConnected += OnPlayerConnected;
}

protected override void Unload()
{
Logger.Log("Example plugin unloaded!");

U.Events.OnPlayerConnected -= OnPlayerConnected;
}

public void OnPlayerConnected(UnturnedPlayer player)
{
// Do something when a player connects
UnturnedChat.Say(Spieler, "Welcome to the server!");
}
}
}

Zu schließen, This plugin will log a message when it is loaded and unloaded, and greet players when they connect to the server. Natürlich, you can customize the plugin to do whatever you want it to do.

Das ist alles, was wir heute dafür teilen Ungedreht Führung. Dieser Leitfaden wurde ursprünglich erstellt und geschrieben von Jdance. Für den Fall, dass wir diesen Leitfaden nicht aktualisieren können, Sie können das neueste Update finden, indem Sie diesem folgen Verknüpfung.

Wenn Sie der Meinung sind, dass der Inhalt dieser Website Ihre Rechte verletzt, einschließlich Ihrer geistigen Eigentumsrechte, Bitte kontaktieren Sie uns umgehend über unser Kontaktformular.
Führer, Videoanleitungen Stichworte:Ungedreht

Beitrags-Navigation

Vorherigen Post: Projekt Spielzeit – How to Change the Cutscenes and Movies
Nächster Beitrag: Disney Dreamlight Valley Kochbuchführer

Schreibe einen Kommentar Antworten abbrechen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

  • Titel: Ungedreht
  • Veröffentlichungsdatum:
  • Entwickler:
  • Herausgeber:
Information about Unturned is still incomplete. Bitte helfen Sie uns dabei, die Details des Spiels auszufüllen Kontaktformular.

Haftungsausschluss

Alle zitierten Inhalte stammen aus den jeweiligen Quellen. Wenn Sie der Meinung sind, dass wir Ihre Inhalte ohne Erlaubnis verwendet haben, Stellen Sie sicher, dass Sie uns erreichen, wir werden es ernst nehmen.
  • Über uns
  • Kontaktiere uns
  • Datenschutz-Bestimmungen
  • Nutzungsbedingungen

Urheberrechte © © 2025 Riot-Bits.

Bereitgestellt von PressBook News WordPress-Theme