1. I'm usgin that:
    Code:
    // Reference: Oxide.Ext.Rustusing System.Collections.Generic;
    using System;
    using UnityEngine;
    using Oxide.Core;
    using Oxide.Core.Plugins;namespace Oxide.Plugins
    {
        [Info("PTest", "Xephiro", "0.0.2")]
        class PTest : RustPlugin
        {
            string Test(string text)
            {        
                return text + " -- CallHook its works!";
            }
        }
    }
    Code:
    // Reference: Oxide.Ext.Rustusing System.Collections.Generic;
    using System;
    using UnityEngine;
    using Oxide.Core;
    using Oxide.Core.Configuration;
    using Oxide.Core.Plugins;namespace Oxide.Plugins
    {
        [Info("MyPlugin", "Xephiro", "0.0.1")]
        class MyPlugin : RustPlugin
        {
            [PluginReference("PTest")]
            private Plugin PluginTest;        void Loaded()
            {
                LoadConfig();
            }        [ChatCommand("testingcallhook")]
            void TestingCallHook(BasePlayer player, string cmd, string[] args)
            {       
                string message = "Hello World!";
                Puts("Plugin Name: {0}", PluginTest.Name);
                message = PluginTest.CallHook("Test", message).ToString();
                ConsoleSystem.Broadcast("chat.add \"SERVER\" " + message.QuoteSafe(), new object[0]);
            }
        }
    }
    And the error persists.

    I have the last version of the server and oxide mod.
     
  2. Are you sure my plugin is being loaded first then ptest?
     
  3. Now its working :S, i change the name of method from Test to NewMethod and this work. Next i change again to Test and works again
    Now its working :p, i change the name of method from Test to NewMethod and this work. Next i change again to Test and works again xD

    Thanks Hatemail for your help!
     
  4. Guys,
    I'm trying to call the C_Balance function from 00-Economics plugin from Bombardir but no success at all until the moment...
    Code:
    [ChatCommand("check")]
            void cmdMoney(BasePlayer player, string command, string[] args)
            {
                var checkMoney = plugins.Find("00-Economics");
                var currentPurse = checkMoney.CallHook("C_Balance", player, "");
                Puts("#################### SUCCESS ####################");
                SendReply(player, "Current money in the purse: "+currentPurse.ToString());
            }
    
    Used that Puts just to confirm if the code was reaching that area, and it is! but when I run check on the game, this is the error that I got:
     
  5. C_Balance needs args to function C_Balance(player, cmd, args) it then checks for the args length which is null because none are submitted.
     
  6. So, how would I call C_Balance within other plugin? I tried "*.CallHook("C_Balance", player, "PlayerName")" and "*.CallHook("C_Balance", "PlayerName")" but none worked.
     
  7. I think the main issue is only Lua can use 00-Economics, it only sends back lua tables instead of data. I've done the same and ran into the same issue, trying to do
    Code:
    EconomyData = GetEconomy.Call("GetUserDataFromPlayer", player);
    
    but I don't get data back only lua tables so I can't use anything from it.
    Since C_Balance takes 3 arguments it would probably be
    Code:
    .Call("C_Balance", player, null, "PlayerName")
    
    Edit:
    When you send "*.CallHook("C_Balance", player, "PlayerName")" then "PlayerName" fills in the cmd argument slot. Maybe null is an incorrect method or maybe you should send cmd instead of null.
     
  8. C_Balance doesn't return anything so why are you trying to get a return value?

    Also the call is just simple: checkMoney.CallHook("C_Balance", player, null, args);
     
  9. Right. I didnt even notice no return.
    What about calling GetUserDataFromPlayer, I am using
    Code:
    GetEconomy = plugins.Find('00-Economics') || false;
    GetEconomy.Call("GetUserDataFromPlayer", player);
    
    But I get
    Code:
    [Oxide] 10:05 PM [Debug] ExType: TargetInvocationException
    [Oxide] 10:05 PM [Error] Failed to call hook 'cmdBounty' on plugin 'Bounty Board
    ' (NullReferenceException: Object reference not set to an instance of an object)
    
    back which I am assuming is because I am getting lua tables back from the function...
     
  10. GetUserDataFromPlayer isn't a plugin function...so you can't call it.
     
  11. I see. So yeah I guess I can't use economics then lol. Thanks for shedding some light.
     
  12. You can call it but it takes a bit of work.
     
  13. Well, right now I think I am going to do resource and item base, and then fiddle with adding economy feature. Plugins been on hold too long, wanna get it done lol.
     
  14. Instructions if you want to attempt.

    Get a reference to the economics plugin.
    Call the GetEconomyAPI function on the stored plugin reference and cast it to a LuaTable.
    Loops through all the tables keys and check if its a lua function, store the function you want to call in a variable.
    Create an array with the table reference and the ags you want to pass to the function.
    Using reflection and the LuaPlugin reference get the Method CallLuaFunction.
    Invoke said method passing in the plugin reference, and an array of the function and arguments.
    Cast results back accordingly.
     
  15. You should rather use the PluginReference C# plugin feature instead of having to use plugins.Find every time you want to call a method. You can find an example of usage in the Rust SamplePlugin.
     
  16. Oh that's interesting to know!
    How would you go about using this feature through JavaScript? Would it just be for example?
    Code:
    var test = Plugin.PluginReference(00-Economics);
    
     
  17. It is a C# plugin specific feature which is exposed via C# custom attributes.
     
  18. Awe poop... Oh well, thanks!