Advertisement
manlymouse2002

HelpCommand Plugin

Oct 28th, 2021
1,402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.08 KB | None | 0 0
  1. using Oxide.Plugins;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Oxide.Core.Libraries.Covalence;
  8.  
  9. namespace Oxide.Plugins
  10. {
  11.     [Info("HelpCommand", "avi", "1.0.1")]
  12.     [Description("Help command")]
  13.     public class HelpCommand : RustPlugin
  14.     {
  15.         private PluginConfig config;
  16.  
  17.         private void Init()
  18.         {
  19.             cmd.AddChatCommand("help", this, "CommandHelp");
  20.             config = Config.ReadObject<PluginConfig>();
  21.         }
  22.  
  23.         private void CommandHelp(BasePlayer player, string help, string[] args)
  24.         {
  25.             PrintWarning("Start");
  26.             string message = lang.GetMessage("HelpFormat", this, player.UserIDString) + "\n";
  27.  
  28.             foreach (KeyValuePair<string, string> commandsDictionary in config.MessageList)
  29.             {
  30.                 string format = lang.GetMessage("CommandFormat", this, player.UserIDString);
  31.                 message += String.Format(format, commandsDictionary.Key, commandsDictionary.Value);
  32.             }
  33.  
  34.             player.ChatMessage(message);
  35.         }
  36.  
  37.         protected override void LoadDefaultConfig()
  38.         {
  39.             Config.WriteObject(GetDefaultConfig(), true);
  40.         }
  41.  
  42.         protected override void LoadDefaultMessages()
  43.         {
  44.             lang.RegisterMessages(new Dictionary<string, string>
  45.             {
  46.                 ["HelpFormat"] = "<color=#ffa500>Here is a list of commands for our server:\n",
  47.                 ["CommandFormat"] = "<color=#ffff>/</color><color=#ffa500>{0}<color=#ffff00>:</color> <color=#ffff00>{1}</color>\n"
  48.             }, this);
  49.         }
  50.  
  51.         private void SaveConfig()
  52.         {
  53.             Config.WriteObject(config, true);
  54.         }
  55.  
  56.         private PluginConfig GetDefaultConfig()
  57.         {
  58.             return new PluginConfig
  59.             {
  60.                 MessageList = new Dictionary<string, string>()
  61.                 {
  62.                     ["mymini"] = "Spawn a minicopter.",
  63.                     ["turret"] = "Turn on any turret you're looking at. Requires ammo and a gun.",
  64.                     ["turret.tc"] = "Turn all turrets connected to your Tool Cupboard on at once. [VIP]",
  65.                     ["skinbox"] = "Skin your items ['Dedicated' rank or VIP.",
  66.                     ["playtime (optional:top)"] = "Check your playtime or the top playtime in the server.",
  67.                     ["bgrade"] = "BGrade lets you automatically upgrade your base to the selected tier when you build. (1 = wood, 2 = stone, etc)",
  68.                     ["up"] = "Upgrade your entire base by 1 tier, or specify the tier with /up (tier) to upgrade everything to that tier directly.",
  69.                     ["down"] = "Downgrade your entire base by 1 tier, or specify the tier with /down (tier) to downgrade everything to that tier directly.",
  70.                     ["limit"] = "Check current entity limit."
  71.                 }
  72.             };
  73.         }
  74.  
  75.         private class PluginConfig
  76.         {
  77.             public Dictionary<string, string> MessageList;
  78.         }
  79.     }
  80. }
  81.  
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement