1. how would I do it? preferably c#
     
  2. Wulf

    Wulf Community Admin

  3. Wulf

    Wulf Community Admin

    I'm sure there are ways to call all, or even just look and find them all, but I'm not sure why you'd need to.
     
  4. No, that's not what I mean. What I mean is like, does a plugin have to have something in the script in order for another plugin to call it?
     
  5. Wulf

    Wulf Community Admin

    You can't call something that doesn't exist.
     
  6. so in other words.... you can call any function in any plugin as long as the plugin have the function?
     
  7. Wulf

    Wulf Community Admin

    Yes, pretty much, as long it isn't a local function.
     
  8. EDIT: I'm trying to call the plugin using
    Code:
    MotdGUI.call((cmdMotdShow(BasePlayer player, string cmd, string[] args));
    but I', keep getting an error... what's wrong with it?
    [DOUBLEPOST=1440120714][/DOUBLEPOST]edit again: fix the error, but now I'm getting this error
    Code:
    error CS1061: Type `Oxide.Core.Plugins.Plugin' does not contain a definition for `call' and no extension method `call' of type `Oxide.Core.Plugins.Plugin' could be found. Are you missing an assembly reference?
    
     
    Last edited by a moderator: Aug 21, 2015
  9. Wulf

    Wulf Community Admin

    Case-sensitivity. ;)
     
  10. thanks, that solves that problem, but now I'm keep getting
    Code:
     error CS1525: Unexpected symbol `)'
    . All I want the plugin to call from Motd is the command function, I have tried
    Code:
    MotdGUI.CallHook((cmdMotdShow(BasePlayer player, string cmd, string[] args)));
    and
    Code:
    MotdGUI.CallHook(cmdMotdShow(BasePlayer player, string cmd, string[] args));
    , but it give me the same error. I have also tried
    Code:
    MotdGUI.CallHook(cmdMotdShow);
    , but I get this
    Code:
    The name `cmdMotdShow' does not exist in the current context
    
     
  11. Wulf

    Wulf Community Admin

    MotdGUI.CallHook("cmdMotdShow", player, cmd, args);
     
  12. It give me an error about args not being valid, so I created a new function in the motd gui that act like the command, then I try calling that function with
    Code:
    MotdGUI.CallHook("AppearGUI");
    and it gave me no errors, but now the plugin doesn't want to do anything... I think I gotta wait for it..
     
  13. Wulf

    Wulf Community Admin

    Try just this:
    Code:
    MotdGUI.CallHook("cmdMotdShow", player)
    There is no function called "AppearGUI" in the Motd GUI plugin.
     
  14. Ik there isn't I added it myself, as for you code, it plugin works, but the gui doesnt appear. Here I'll just send you the part of the code that I'm trying to call from (happy hour)
    Code:
    //Microsoft NameSpaces
    using System;
    using System.Collections.Generic;//using UnityEngine;
    //Oxide NameSpaces
    using Oxide.Core;
    using Oxide.Core.Plugins;
    using Oxide.Core.Libraries;
    //using Rust;//External NameSpaces
    using Newtonsoft.Json;        private void HappyHours(object sender , object PairObj)
            {
                HappyHour myPlugin = (HappyHour)sender;
                KeyValuePair<string, object> pair = (KeyValuePair<string, object>)PairObj;
                long CurrentTime = MainTime.GetUnixTimestamp();
                Dictionary<string, object> Event = (Dictionary<string, object>)pair.Value;
                if (CurrentTime < (Convert.ToInt64(Event["NextEvent"].ToString()) + Convert.ToInt64(myPlugin.Config["Time"].ToString())))
                {
                    foreach (BasePlayer Player in BasePlayer.activePlayerList)
                    {
                        if (myPlugin.Users.ContainsKey(Player.userID.ToString()) == false)
                        {
                            myPlugin.myPrintToChat(Player, Event["Message"].ToString());
                            Dictionary<string, object> Items = (Dictionary<string, object>)Event["Items"];
                            foreach (KeyValuePair<string, object> zItem in (Dictionary<string, object>)Items)
                            {
                                Dictionary<string, object> ItemVars = (Dictionary<string, object>)zItem.Value;
                                Item newItem = ItemManager.CreateByName(ItemVars["ID"].ToString(), Convert.ToInt32(ItemVars["Amount"].ToString()));
                                ItemContainer Cont = null;
                                switch (ItemVars["Amount"].ToString())
                                {
                                    case "Belt":
                                        Cont = Player.inventory.containerBelt;
                                        break;
                                    case "Wear":
                                        Cont = Player.inventory.containerWear;
                                        break;
                                    default:
                                        Cont = Player.inventory.containerMain;
                                        break;
                                }
                                Player.inventory.GiveItem(newItem, Cont);
                            }
                            myPlugin.Users.Add(Player.userID.ToString(), CurrentTime.ToString());
                            //*****************************MotdGUI.CallHook("cmdMotdShow", player);
                        }
                    }
                    myPlugin.mySaveData();
                    Oxide.Core.Libraries.Timer.TimerInstance newTimer = MainTimer.Once(1, () => HappyHours(sender, PairObj), (Plugin)sender);
                    Timers.Add(newTimer);
                }
    here's my edit version of motd
    Code:
    using UnityEngine;
    using Rust;
    using Oxide.Core.Plugins;namespace Oxide.Plugins
    {
        [Info("Motd GUI", "PaiN", 0.1, ResourceId = 0)]
        [Description("Simple Motd on the screen.")]
        public class MotdGUI : RustPlugin
        {  
     
            System.Collections.Generic.List<ulong> guioff = new System.Collections.Generic.List<ulong>(); 
         
            void Loaded()
            {
                LoadDefaultConfig();
                foreach(BasePlayer player in BasePlayer.activePlayerList)
                {
                string text = Config["Motd", "Message"].ToString();
                string title = Config["Motd", "Title"].ToString();
                CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = player.net.connection }, null, "AddUI", json.Replace("{text}", text).Replace("{title}", title));
                }
            }
         
            protected override void LoadDefaultConfig()
            {
         
            if(Config["Motd", "Message"] == null) Config["Motd", "Message"] = "<color=yellow>Today</color> is a beautiful day!";
            if(Config["Motd", "Message"].ToString() != "<color=yellow>Today</color> is a beautiful day!") return;        if(Config["Motd", "Title"] == null) Config["Motd", "Title"] = "<color=red>Motd</color>";
            if(Config["Motd", "Title"].ToString() != "<color=red>Motd</color>") return;
         
         
            SaveConfig();
            }
          
            #region JSON
            string json = @"[
                           {
                                ""name"": ""Motd"",
                                ""parent"": ""Overlay"",
                                ""components"":
                                [
                                    {
                                         ""type"":""UnityEngine.UI.Image"",
                                         ""color"":""0.1 0.1 0.1 0"",
                                    },
                                    {
                                        ""type"":""RectTransform"",
                                        ""anchormin"": ""0.3 0.90"",
                                        ""anchormax"": ""0.7 0.995""
                                    }
                                ]
                            },
                            {
                                ""parent"": ""Motd"",
                                ""components"":
                                [
                                    {
                                        ""type"":""UnityEngine.UI.Text"",
                                        ""text"":""{title}"",
                                        ""fontSize"":20,
                                        ""align"": ""MiddleCenter"",
                                    },
                                    {
                                        ""type"":""RectTransform"",
                                        ""anchormin"": ""0 0.7"",
                                        ""anchormax"": ""1 1""
                                    }
                                ]
                            },
                            {
                                ""parent"": ""Motd"",
                                ""components"":
                                [
                                    {
                                        ""type"":""UnityEngine.UI.Text"",
                                        ""text"":""{text}"",
                                        ""fontSize"":15,
                                        ""align"": ""MiddleCenter"",
                                    },
                                    {
                                        ""type"":""RectTransform"",
                                        ""anchormin"": ""0 0.1"",
                                        ""anchormax"": ""1 1.2""
                                    }
                                ]
                            }
                        ]
                        ";
            #endregion
       
            [ChatCommand("motd")]
            void cmdMotdShow(BasePlayer player, string cmd, string[] args)
            {
                if(guioff.Contains(player.userID))
                {             
                string text = Config["Motd", "Message"].ToString();
                string title = Config["Motd", "Title"].ToString();
                CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = player.net.connection }, null, "AddUI", json.Replace("{text}", text).Replace("{title}", title));
                    guioff.Remove(player.userID);
                }
                else
                {
                    CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = player.net.connection }, null, "DestroyUI", "Motd");
                    guioff.Add(player.userID);
                } 
         
         
            }        void AppearGUI()
            {
                foreach (BasePlayer player in BasePlayer.activePlayerList)
                {
                    string text = Config["Motd", "Message"].ToString();
                    string title = Config["Motd", "Title"].ToString();
                    CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = player.net.connection }, null, "AddUI", json.Replace("{text}", text).Replace("{title}", title));
                    guioff.Remove(player.userID);
                }
            }        void DisGUI()
            {
                foreach (BasePlayer current in BasePlayer.activePlayerList)
                {
                    CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = current.net.connection }, null, "DestroyUI", "Motd");
                    guioff.Add(player.userID);            }
            }
          
            [HookMethod("OnPlayerInit")]
            void OnPlayerInit(BasePlayer player)
            {
                CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = player.net.connection }, null, "DestroyUI", "Motd");
                guioff.Add(player.userID);
            }
         
            void Unloaded(BasePlayer player)
            {
                foreach (BasePlayer current in BasePlayer.activePlayerList)
                {
                    CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = current.net.connection }, null, "DestroyUI", "Motd");
             
                }
         
            }
            void OnPlayerDisconnected(BasePlayer player)
            {
                CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = player.net.connection }, null, "DestroyUI", "Motd");
                guioff.Add(player.userID);
            }
        }
    }
     

    Attached Files:

    Last edited by a moderator: Aug 21, 2015
  15. If you want examples lots of my plugin use that.
    Évent Manager, Arena Deathmatch, HumanNPC, Jail, etc