Ga naar de inhoud
Rel-bits

Rel-bits

  • Thuis
  • Nieuws
  • Gidsen
  • Videogidsen
  • Patch-opmerkingen
  • Misbruik melden
  • Toggle zoekformulier

Ongedraaid – How to Create a Plugin

Geplaatst op 12/14/2022 Deur Jdance Geen reacties op Ongedraaid – How to Create a Plugin
  • Titel: Ongedraaid
  • Releasedatum:
  • Ontwikkelaar:
  • Uitgever:
Informatie over ongedwongen is nog steeds onvolledig. Help ons alstublieft de details van het spel hiermee in te vullen contactformulier.

A guide on creating your first plugin.

Informatie

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.

Verder gaan, 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(speler, "Welcome to the server!");
}
}
}

To conclude, This plugin will log a message when it is loaded and unloaded, and greet players when they connect to the server. Natuurlijk, you can customize the plugin to do whatever you want it to do.

Dat is alles wat we vandaag hiervoor delen Ongedraaid gids. Deze handleiding is oorspronkelijk gemaakt en geschreven door Jdance. Voor het geval we er niet in slagen deze handleiding bij te werken, U kunt de laatste update vinden door dit te volgen link.

Als u van mening bent dat de inhoud van deze site uw rechten schendt, inclusief uw intellectuele eigendomsrechten, neem dan direct contact met ons op via ons contactformulier.
Gidsen, Videogidsen Labels:Ongedraaid

Bericht navigatie

Vorig bericht: Project Playtime – How to Change the Cutscenes and Movies
Volgende bericht: Disney Dreamlight Valley Cookbook Guide

Geef een reactie Reactie annuleren

Je e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *

  • Titel: Ongedraaid
  • Releasedatum:
  • Ontwikkelaar:
  • Uitgever:
Informatie over ongedwongen is nog steeds onvolledig. Help ons alstublieft de details van het spel hiermee in te vullen contactformulier.

Vrijwaring

Alle geciteerde inhoud is afgeleid van hun respectieve bronnen. Als u denkt dat wij uw inhoud zonder toestemming hebben gebruikt, Zorg ervoor dat u ons bereikt en wij zullen het serieus nemen.
  • Over ons
  • Neem contact met ons op
  • Privacybeleid
  • Servicevoorwaarden

Auteursrecht © 2025 Rel-bits.

Aangedreven door PersBoek Nieuws WordPress thema