Aller au contenu
Morceaux d'émeute

Morceaux d'émeute

  • Maison
  • Nouvelles
  • Guides
  • Guides vidéo
  • Notes de mise à jour
  • Signaler un abus
  • Basculer le formulaire de recherche

Non retourné – How to Create a Plugin

Posté sur 12/14/2022 Par Jdance Aucun commentaire sur Non retourné – How to Create a Plugin
  • Titre: Non retourné
  • Date de sortie:
  • Promoteur:
  • Éditeur:
Les informations sur non retournées sont toujours incomplètes. S'il vous plaît, aidez-nous à remplir les détails du jeu en utilisant ceci formulaire de contact.

A guide on creating your first plugin.

Information

Toi’ll probably need Visual Studio 2019 Community Edition. Alongside that, ce guide ne’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.

Passer à autre chose, 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(joueur, "Welcome to the server!");
}
}
}

Pour conclure, This plugin will log a message when it is loaded and unloaded, and greet players when they connect to the server. Bien sûr, you can customize the plugin to do whatever you want it to do.

C'est tout ce que nous partageons aujourd'hui pour cela Non retourné guide. Ce guide a été initialement créé et rédigé par Jdance. Si nous ne parvenons pas à mettre à jour ce guide, vous pouvez trouver la dernière mise à jour en suivant ceci lien.

Si vous pensez que le contenu de ce site viole vos droits, y compris vos droits de propriété intellectuelle, veuillez nous contacter immédiatement en utilisant notre formulaire de contact.
Guides, Guides vidéo Mots clés:Non retourné

Navigation de l’article

Post précédent: Temps de jeu du projet – How to Change the Cutscenes and Movies
Prochain article: Guide des livres de recettes Disney Dreamlight Valley

Laisser un commentaire Annuler la réponse

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

  • Titre: Non retourné
  • Date de sortie:
  • Promoteur:
  • Éditeur:
Les informations sur non retournées sont toujours incomplètes. S'il vous plaît, aidez-nous à remplir les détails du jeu en utilisant ceci formulaire de contact.

Clause de non-responsabilité

Tout le contenu cité est dérivé de leurs sources respectives. Si vous pensez que nous avons utilisé votre contenu sans autorisation, assurez-vous de nous joindre et nous le prendrons au sérieux.
  • À propos de nous
  • Contactez-nous
  • politique de confidentialité
  • Conditions d'utilisation

droits d'auteur © 2025 Morceaux d'émeute.

Alimenté par Actualité PressBook Thème WordPress