void Loaded() { LoadDefaultConfig(); command.AddChatCommand("eventon", this, "cmdEvent"); command.AddChatCommand("eventoff", this, "cmdEventOff"); command.AddChatCommand("run", this, "cmdRun"); command.AddConsoleCommand("eventon", this, "ccmdEvent"); command.AddConsoleCommand("eventoff", this, "cmdEventOf"); EventStarted = false; if (!Economics) { Puts("Economics not found!"); } if ((string)Config["Default", "AutoStart"] == "true" && (string)Config["IngameTime", "Use ingame timer"] == "false") { eventpause = timer.Once(60 * (int)Config["Default", "PauseeventTime"], Startevent); time1 = DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; } else if ((string)Config["Default", "AutoStart"] == "true" && (string)Config["IngameTime", "Use ingame timer"] == "true") { ingameTimer = timer.Once(20, CheckTime); CheckTime(); } LoadSavedData(); }
public override void HandleAddedToManager(PluginManager manager) { #region Command Attributes foreach (var method in GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)) { var attributes = method.GetCustomAttributes(typeof(ConsoleCommandAttribute), true); if (attributes.Length > 0) { var attribute = attributes[0] as ConsoleCommandAttribute; cmd.AddConsoleCommand(attribute?.Command, this, method.Name); continue; } attributes = method.GetCustomAttributes(typeof(ChatCommandAttribute), true); if (attributes.Length > 0) { var attribute = attributes[0] as ChatCommandAttribute; cmd.AddChatCommand(attribute?.Command, this, method.Name); } } #endregion base.HandleAddedToManager(manager); }
private void Init() { // Configure remote logging RemoteLogger.SetTag("game", "rust"); RemoteLogger.SetTag("version", Protocol.printable); // Register messages for localization lang.RegisterMessages(messages, this); // Add general console commands cmdlib.AddConsoleCommand("oxide.plugins", this, "CmdPlugins"); cmdlib.AddConsoleCommand("global.plugins", this, "CmdPlugins"); cmdlib.AddConsoleCommand("oxide.load", this, "CmdLoad"); cmdlib.AddConsoleCommand("global.load", this, "CmdLoad"); cmdlib.AddConsoleCommand("oxide.unload", this, "CmdUnload"); cmdlib.AddConsoleCommand("global.unload", this, "CmdUnload"); cmdlib.AddConsoleCommand("oxide.reload", this, "CmdReload"); cmdlib.AddConsoleCommand("global.reload", this, "CmdReload"); cmdlib.AddConsoleCommand("oxide.version", this, "CmdVersion"); //cmdlib.AddConsoleCommand("global.version", this, "CmdVersion"); cmdlib.AddConsoleCommand("oxide.lang", this, "CmdLang"); cmdlib.AddConsoleCommand("global.lang", this, "CmdLang"); // Add general chat commands cmdlib.AddChatCommand("lang", this, CmdChatLang); // Add permission console commands cmdlib.AddConsoleCommand("oxide.group", this, "CmdGroup"); cmdlib.AddConsoleCommand("global.group", this, "CmdGroup"); cmdlib.AddConsoleCommand("oxide.usergroup", this, "CmdUserGroup"); cmdlib.AddConsoleCommand("global.usergroup", this, "CmdUserGroup"); cmdlib.AddConsoleCommand("oxide.grant", this, "CmdGrant"); cmdlib.AddConsoleCommand("global.grant", this, "CmdGrant"); cmdlib.AddConsoleCommand("oxide.revoke", this, "CmdRevoke"); cmdlib.AddConsoleCommand("global.revoke", this, "CmdRevoke"); cmdlib.AddConsoleCommand("oxide.show", this, "CmdShow"); cmdlib.AddConsoleCommand("global.show", this, "CmdShow"); if (permission.IsLoaded) { var rank = 0; for (var i = DefaultGroups.Length - 1; i >= 0; i--) { var defaultGroup = DefaultGroups[i]; if (!permission.GroupExists(defaultGroup)) { permission.CreateGroup(defaultGroup, defaultGroup, rank++); } } permission.CleanUp(s => { ulong temp; return(ulong.TryParse(s, out temp)); }); } }
void Loaded() { permission.RegisterPermission("give.use", this); cmdlib.AddChatCommand("give", this, "cmdGive"); cmdlib.AddChatCommand("giveme", this, "cmdGiveMe"); lang.RegisterMessages(new Dictionary <string, string> { { "giveItemSyn", "<color=#C4FF00>/give item <playername> <itemname/id> <amount></color> - Give <playername> a item, using ID# or partial name" }, { "giveVehicleSyn", "<color=#C4FF00>/give vehicle <playername> <vehiclename/id></color> - Give <playername> a vehicle, using ID# or partial name" }, { "noPlayers", "Could not find any players with the name <color=#C4FF00>{0}</color>" }, { "multiPlayers", "Multiple players found with the name <color=#C4FF00>{0}</color>" }, { "givenItem", "You have given <color=#C4FF00>{0} {1}x {2}</color>" }, { "receivedItem", "You have received <color=#C4FF00>{0}x {1}</color>" }, { "givenVehicle", "You have given <color=#C4FF00>{0} a {1}</color>" }, { "receivedVehicle", "You have received a <color=#C4FF00>{0}</color>" }, { "incSyn", "<color=#C4FF00>Incorrect Syntax!</color>" }, { "title", "<color=#C4FF00>Give:</color> " }, { "noPerms", "You do not have permission to use this command!" }, { "givemeItem", "<color=#C4FF00>/giveme item <itemname/id> <amount></color> - Give youself a item, using ID# or partial name" }, { "givemeVehicle", "<color=#C4FF00>/giveme vehicle <vehiclename/id></color> - Give youself a vehicle, using ID# or partial name" }, { "noFind", "Unable to find the item/vehicle you were searching for" } }, this); }
void Loaded() { LoadData(); LoadConfig(); LoadMessages(); RegisterPerm("mute"); RegisterPerm("formatting"); foreach (var kvp in Config) { string group = kvp.Key; if (group == "Mute" || group == "WordFilter" || group == "AntiSpam") { continue; } RegisterPerm(GetConfig(group, group, "Permission")); //BroadcastChat($"--> <color=red>Registered permission '{PermissionPrefix}.{GetConfig(group, group, "Permission")}'</color>"); if (!permission.GroupExists(group)) { permission.CreateGroup(group, GetConfig("[Player]", group, "Title"), GetConfig(1, group, "Rank")); //BroadcastChat($"--> <color=red>Created group '{group}' as it did not exist</color>"); } permission.GrantGroupPermission(group, $"{PermissionPrefix}.{GetConfig(group, group, "Permission")}", this); //BroadcastChat($"--> <color=red>Granted permission '{PermissionPrefix}.{GetConfig(group, group, "Permission")}' to group '{group}'</color>"); } if (GetConfig(true, "Mute", "Enabled")) { commands.AddChatCommand("mute", this, "cmdMute"); commands.AddChatCommand("unmute", this, "cmdUnmute"); } }
public override void HandleAddedToManager(PluginManager manager) { foreach (FieldInfo field in GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance)) { object[] attributes = field.GetCustomAttributes(typeof(OnlinePlayersAttribute), true); if (attributes.Length > 0) { PluginFieldInfo pluginField = new PluginFieldInfo(this, field); if (pluginField.GenericArguments.Length != 2 || pluginField.GenericArguments[0] != typeof(Player)) { Puts($"The {field.Name} field is not a Hash with the player key! (online players will not be tracked)"); continue; } if (!pluginField.LookupMethod("Add", pluginField.GenericArguments)) { Puts($"The {field.Name} field does not support adding Player keys! (online players will not be tracked)"); continue; } if (!pluginField.LookupMethod("Remove", typeof(Player))) { Puts($"The {field.Name} field does not support removing Player keys! (online players will not be tracked)"); continue; } if (pluginField.GenericArguments[1].GetField("Player") == null) { Puts($"The {pluginField.GenericArguments[1].Name} class does not have a public Player field! (online players will not be tracked)"); continue; } onlinePlayerFields.Add(pluginField); } } foreach (MethodInfo method in GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)) { object[] attributes = method.GetCustomAttributes(typeof(ChatCommandAttribute), true); if (attributes.Length <= 0) { continue; } ChatCommandAttribute attribute = attributes[0] as ChatCommandAttribute; cmd.AddChatCommand(attribute?.Command, this, method.Name); } base.HandleAddedToManager(manager); }
//////////////////////////////////////// /// Plugin Hooks //////////////////////////////////////// void Loaded() { #if !HURTWORLD throw new NotSupportedException("This plugin or the version of this plugin does not support this game!"); #endif LoadData(); LoadConfig(); LoadMessages(); command = GetConfig("money", "Settings", "Command"); foreach (PlayerSession player in GameManager.Instance.GetSessions().Values) { CheckForAccount(player); } commands.AddChatCommand(command, this, "cmdMoney"); RegisterPerm("admin"); }
/// <summary> /// Initializes a new instance of the ReignOfKingsCore class /// </summary> public ReignOfKingsCore() { // Set attributes Name = "ReignOfKingsCore"; Title = "Reign of Kings"; Author = "Oxide Team"; Version = new VersionNumber(1, 0, 0); var plugins = Interface.Oxide.GetLibrary <Core.Libraries.Plugins>(); if (plugins.Exists("unitycore")) { InitializeLogging(); } CommandManager.OnRegisterCommand += (attribute) => { foreach (var command in attribute.Aliases.InsertItem(attribute.Name, 0)) { Command.ChatCommand chatCommand; if (cmdlib.ChatCommands.TryGetValue(command, out chatCommand)) { cmdlib.ChatCommands.Remove(chatCommand.Name); cmdlib.AddChatCommand(chatCommand.Name, chatCommand.Plugin, chatCommand.Callback); } ReignOfKingsCommandSystem.RegisteredCommand covalenceCommand; if (Covalence.CommandSystem.registeredCommands.TryGetValue(command, out covalenceCommand)) { Covalence.CommandSystem.registeredCommands.Remove(covalenceCommand.Command); Covalence.CommandSystem.RegisterCommand(covalenceCommand.Command, covalenceCommand.Source, covalenceCommand.Callback); } } }; }
/// <summary> /// Initializes a new instance of the ReignOfKingsCore class /// </summary> public ReignOfKingsCore() { // Set plugin info attributes Title = "Reign of Kings"; Author = "Oxide Team"; var assemblyVersion = ReignOfKingsExtension.AssemblyVersion; Version = new VersionNumber(assemblyVersion.Major, assemblyVersion.Minor, assemblyVersion.Build); CommandManager.OnRegisterCommand += (attribute) => { foreach (var command in attribute.Aliases.InsertItem(attribute.Name, 0)) { Command.ChatCommand chatCommand; if (cmdlib.ChatCommands.TryGetValue(command, out chatCommand)) { cmdlib.ChatCommands.Remove(chatCommand.Name); cmdlib.AddChatCommand(chatCommand.Name, chatCommand.Plugin, chatCommand.Callback); } ReignOfKingsCommandSystem.RegisteredCommand covalenceCommand; if (Covalence.CommandSystem.registeredCommands.TryGetValue(command, out covalenceCommand)) { Covalence.CommandSystem.registeredCommands.Remove(covalenceCommand.Command); Covalence.CommandSystem.RegisterCommand(covalenceCommand.Command, covalenceCommand.Source, covalenceCommand.Callback); } } }; }
private void Init() { // Configure remote logging RemoteLogger.SetTag("game", Title.ToLower()); RemoteLogger.SetTag("game version", GameInfo.VersionString); // Add general commands cmdlib.AddChatCommand("oxide.plugins", this, "ChatPlugins"); cmdlib.AddChatCommand("plugins", this, "ChatPlugins"); cmdlib.AddChatCommand("oxide.load", this, "ChatLoad"); cmdlib.AddChatCommand("load", this, "ChatLoad"); cmdlib.AddChatCommand("oxide.unload", this, "ChatUnload"); cmdlib.AddChatCommand("unload", this, "ChatUnload"); cmdlib.AddChatCommand("oxide.reload", this, "ChatReload"); cmdlib.AddChatCommand("reload", this, "ChatReload"); cmdlib.AddChatCommand("oxide.version", this, "ChatVersion"); cmdlib.AddChatCommand("version", this, "ChatVersion"); // Add permission commands cmdlib.AddChatCommand("oxide.group", this, "ChatGroup"); cmdlib.AddChatCommand("group", this, "ChatGroup"); cmdlib.AddChatCommand("oxide.usergroup", this, "ChatUserGroup"); cmdlib.AddChatCommand("usergroup", this, "ChatUserGroup"); cmdlib.AddChatCommand("oxide.grant", this, "ChatGrant"); cmdlib.AddChatCommand("grant", this, "ChatGrant"); cmdlib.AddChatCommand("oxide.revoke", this, "ChatRevoke"); cmdlib.AddChatCommand("revoke", this, "ChatRevoke"); cmdlib.AddChatCommand("oxide.show", this, "ChatShow"); cmdlib.AddChatCommand("show", this, "ChatShow"); }
private void Init() { // Configure remote logging RemoteLogger.SetTag("game", "hide & hold out"); RemoteLogger.SetTag("version", NetworkController.NetManager_.get_GAME_VERSION); // Register messages for localization lang.RegisterMessages(messages, this); // Add general chat commands //cmdlib.AddChatCommand("oxide.plugins", this, "CmdPlugins"); //cmdlib.AddChatCommand("plugins", this, "CmdPlugins"); /*cmdlib.AddChatCommand("oxide.load", this, "CmdLoad"); * cmdlib.AddChatCommand("load", this, "CmdLoad"); * cmdlib.AddChatCommand("oxide.unload", this, "CmdUnload"); * cmdlib.AddChatCommand("unload", this, "CmdUnload"); * cmdlib.AddChatCommand("oxide.reload", this, "CmdReload"); * cmdlib.AddChatCommand("reload", this, "CmdReload");*/ cmdlib.AddChatCommand("oxide.version", this, "CmdVersion"); cmdlib.AddChatCommand("version", this, "CmdVersion"); cmdlib.AddConsoleCommand("oxide.version", this, "CmdVersion"); cmdlib.AddConsoleCommand("version", this, "CmdVersion"); // Add permission chat commands /*cmdlib.AddChatCommand("oxide.group", this, "CmdGroup"); * cmdlib.AddChatCommand("group", this, "CmdGroup"); * cmdlib.AddChatCommand("oxide.usergroup", this, "CmdUserGroup"); * cmdlib.AddChatCommand("usergroup", this, "CmdUserGroup"); * cmdlib.AddChatCommand("oxide.grant", this, "CmdGrant"); * cmdlib.AddChatCommand("grant", this, "CmdGrant"); * cmdlib.AddChatCommand("oxide.revoke", this, "CmdRevoke"); * cmdlib.AddChatCommand("revoke", this, "CmdRevoke"); * cmdlib.AddChatCommand("oxide.show", this, "CmdShow"); * cmdlib.AddChatCommand("show", this, "CmdShow");*/ if (permission.IsLoaded) { var rank = 0; for (var i = DefaultGroups.Length - 1; i >= 0; i--) { var defaultGroup = DefaultGroups[i]; if (!permission.GroupExists(defaultGroup)) { permission.CreateGroup(defaultGroup, defaultGroup, rank++); } } permission.RegisterValidate(s => { ulong temp; if (!ulong.TryParse(s, out temp)) { return(false); } var digits = temp == 0 ? 1 : (int)Math.Floor(Math.Log10(temp) + 1); return(digits >= 17); }); permission.CleanUp(); } }
private void Init() { // Configure remote logging RemoteLogger.SetTag("game", "rust"); RemoteLogger.SetTag("version", BuildInformation.VersionStampDays.ToString()); // Register messages for localization lang.RegisterMessages(messages, this); // Add general commands cmdlib.AddConsoleCommand("oxide.plugins", this, "ConsolePlugins"); cmdlib.AddConsoleCommand("global.plugins", this, "ConsolePlugins"); cmdlib.AddConsoleCommand("oxide.load", this, "ConsoleLoad"); cmdlib.AddConsoleCommand("global.load", this, "ConsoleLoad"); cmdlib.AddConsoleCommand("oxide.unload", this, "ConsoleUnload"); cmdlib.AddConsoleCommand("global.unload", this, "ConsoleUnload"); cmdlib.AddChatCommand("reload", this, "ChatReload"); cmdlib.AddConsoleCommand("oxide.reload", this, "ConsoleReload"); cmdlib.AddConsoleCommand("global.reload", this, "ConsoleReload"); cmdlib.AddChatCommand("version", this, "ChatVersion"); cmdlib.AddChatCommand("oxide.version", this, "ChatVersion"); cmdlib.AddConsoleCommand("oxide.version", this, "ConsoleVersion"); cmdlib.AddChatCommand("lang", this, "ChatLang"); cmdlib.AddConsoleCommand("oxide.lang", this, "ConsoleLang"); cmdlib.AddConsoleCommand("global.lang", this, "ConsoleLang"); // Add permission commands cmdlib.AddConsoleCommand("oxide.group", this, "ConsoleGroup"); cmdlib.AddConsoleCommand("global.group", this, "ConsoleGroup"); cmdlib.AddConsoleCommand("oxide.usergroup", this, "ConsoleUserGroup"); cmdlib.AddConsoleCommand("global.usergroup", this, "ConsoleUserGroup"); cmdlib.AddConsoleCommand("oxide.grant", this, "ConsoleGrant"); cmdlib.AddConsoleCommand("global.grant", this, "ConsoleGrant"); cmdlib.AddConsoleCommand("oxide.revoke", this, "ConsoleRevoke"); cmdlib.AddConsoleCommand("global.revoke", this, "ConsoleRevoke"); cmdlib.AddConsoleCommand("oxide.show", this, "ConsoleShow"); cmdlib.AddConsoleCommand("global.show", this, "ConsoleShow"); if (permission.IsLoaded) { var rank = 0; for (var i = DefaultGroups.Length - 1; i >= 0; i--) { var defaultGroup = DefaultGroups[i]; if (!permission.GroupExists(defaultGroup)) { permission.CreateGroup(defaultGroup, defaultGroup, rank++); } } permission.RegisterValidate(s => { ulong temp; if (!ulong.TryParse(s, out temp)) { return(false); } var digits = temp == 0 ? 1 : (int)Math.Floor(Math.Log10(temp) + 1); return(digits >= 17); }); permission.CleanUp(); } }