Иконка ресурса

FREE PTest : 1.0.0 1.0.0

Нет прав для скачивания
C#:
---
layout: forums
title: 'Solved - Run a function from another PLUGIN if it doesn't have an API function? | Page 2'
breadcrumbs:
 - "Plugin Development": "/forums/plugin-development.105/"
 - "Rust Development": "/forums/rust-development.4/"
---
<div class="titleBar">
    <h1>
        <span class="prefix prefixGreen">Solved</span> <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/' | prepend: site.baseurl }}">Run a function from
            another PLUGIN if it doesn&#039;t have an API function?</a>
    </h1>
    <p id="pageDescription" class="muted">Discussion in '<a href="{{ '/forums/rust-development.4/' | prepend: site.baseurl }}">Rust Development</a>' started by <a class="username"
            dir="auto">TheRotAG</a>, <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/' | prepend: site.baseurl }}"><span class="DateTime"
                title="Feb 10, 2015 at 1:23 AM">Feb 10, 2015</span></a>.
    </p>
</div>
<div class="pageNavLinkGroup">
    <div class="linkGroup SelectionCountContainer">
    </div>
    <div class="PageNav" data-page="2" data-range="2" data-start="2" data-end="2" data-last="2" data-sentinel="{sentinel}"
        data-baseurl="page-{sentinel}">
        <nav>
            <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/' | prepend: site.baseurl }}" class="text">&lt; Prev</a>
            <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/' | prepend: site.baseurl }}" class="" rel="start">1</a>
            <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2' | prepend: site.baseurl }}" class="currentPage ">2</a>
        </nav>
    </div>
</div>
<ol class="messageList" id="messageList">
    <li id="post-70157" class="message" data-author="Xephiro">
        <div class="messageUserInfo">
            <div class="messageUserBlock">
                <div class="avatarHolder">
                    <span class="helper"></span>
                    <a class="avatar Avm" data-avatarhtml="true"><img src="{{ '/assets/styles/oxide/logo.og.png' | prepend: site.baseurl }}" width="96" height="96" alt="Xephiro" /></a>
                </div>
                <h3 class="userText">
                    <a class="username" dir="auto">Xephiro</a>
                </h3>
                <span class="arrow"></span>
            </div>
        </div>
        <div class="messageInfo primaryContent">
            <div class="messageContent">
                <article>
                    <blockquote class="messageText SelectQuoteContainer ugc baseHtml">
                        <div class="bbCodeBlock bbCodeQuote" data-author="Hatemail">
                            <aside>
                                <div class="attribution type">Hatemail said: <a href="#post-70144" class="AttributionLink">&uarr;</a>
                                </div>
                                <blockquote class="quoteContainer">
                                    <div class="quote">HookMethod is only needed if you wanted you hook method to be public.</div>
                                    <div class="quoteExpand">Click to expand...</div>
                                </blockquote>
                            </aside>
                        </div>I&#039;m usgin that:<br />
                        <div class="bbCodeBlock bbCodeCode">
                            <div class="type">Code:</div>
                            {% raw %}<pre>// Reference: Oxide.Ext.Rustusing System.Collections.Generic;
using System;
using UnityEngine;
using Oxide.Core;
using Oxide.Core.Plugins;namespace Oxide.Plugins
{
    [Info(&quot;PTest&quot;, &quot;Xephiro&quot;, &quot;0.0.2&quot;)]
    class PTest : RustPlugin
    {
        string Test(string text)
        {        
            return text + &quot; -- CallHook its works!&quot;;
        }
    }
}</pre>{% endraw %}
                        </div>
                        <div class="bbCodeBlock bbCodeCode">
                            <div class="type">Code:</div>
                            {% raw %}<pre>// 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(&quot;MyPlugin&quot;, &quot;Xephiro&quot;, &quot;0.0.1&quot;)]
    class MyPlugin : RustPlugin
    {
        [PluginReference(&quot;PTest&quot;)]
        private Plugin PluginTest;        void Loaded()
        {
            LoadConfig();
        }        [ChatCommand(&quot;testingcallhook&quot;)]
        void TestingCallHook(BasePlayer player, string cmd, string[] args)
        {       
            string message = &quot;Hello World!&quot;;
            Puts(&quot;Plugin Name: {0}&quot;, PluginTest.Name);
            message = PluginTest.CallHook(&quot;Test&quot;, message).ToString();
            ConsoleSystem.Broadcast(&quot;chat.add \&quot;SERVER\&quot; &quot; + message.QuoteSafe(), new object[0]);
        }
    }
}</pre>{% endraw %}
                        </div>And the error persists.<br />
                        <br /> I have the last version of the server and oxide mod. <div class="messageTextEndMarker">&nbsp;</div>
                    </blockquote>
                </article>
            </div>
            <div class="messageMeta ToggleTriggerAnchor">
                <div class="privateControls">
                    <span class="item muted">
                        <span class="authorEnd"><a class="username author" dir="auto">Xephiro</a>,</span>
                        <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-70157' | prepend: site.baseurl }}" title="Permalink"
                            class="datePermalink"><span class="DateTime" title="Feb 27, 2015 at 2:26 AM">Feb 27, 2015</span></a>
                    </span>
                </div>
                <div class="publicControls">
                    <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-70157' | prepend: site.baseurl }}" title="Permalink"
                        class="item muted postNumber hashPermalink OverlayTrigger" data-href="posts/70157/permalink">#21</a>
                </div>
            </div>
        </div>
    </li>
    <li id="post-70160" class="message" data-author="Hatemail">
        <div class="messageUserInfo">
            <div class="messageUserBlock">
                <div class="avatarHolder">
                    <span class="helper"></span>
                    <a class="avatar Avm" data-avatarhtml="true"><img src="{{ '/assets/styles/oxide/logo.og.png' | prepend: site.baseurl }}" width="96" height="96" alt="Hatemail" /></a>
                </div>
                <h3 class="userText">
                    <a class="username" dir="auto">Hatemail</a>
                </h3>
                <span class="arrow"></span>
            </div>
        </div>
        <div class="messageInfo primaryContent">
            <div class="messageContent">
                <article>
                    <blockquote class="messageText SelectQuoteContainer ugc baseHtml"> Are you sure my plugin is being loaded first then ptest? <div class="messageTextEndMarker">&nbsp;</div>
                    </blockquote>
                </article>
            </div>
            <div class="messageMeta ToggleTriggerAnchor">
                <div class="privateControls">
                    <span class="item muted">
                        <span class="authorEnd"><a class="username author" dir="auto">Hatemail</a>,</span>
                        <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-70160' | prepend: site.baseurl }}" title="Permalink"
                            class="datePermalink"><span class="DateTime" title="Feb 27, 2015 at 2:49 AM">Feb 27, 2015</span></a>
                    </span>
                </div>
                <div class="publicControls">
                    <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-70160' | prepend: site.baseurl }}" title="Permalink"
                        class="item muted postNumber hashPermalink OverlayTrigger" data-href="posts/70160/permalink">#22</a>
                </div>
            </div>
        </div>
    </li>
    <li id="post-70161" class="message" data-author="Xephiro">
        <div class="messageUserInfo">
            <div class="messageUserBlock">
                <div class="avatarHolder">
                    <span class="helper"></span>
                    <a class="avatar Avm" data-avatarhtml="true"><img src="{{ '/assets/styles/oxide/logo.og.png' | prepend: site.baseurl }}" width="96" height="96" alt="Xephiro" /></a>
                </div>
                <h3 class="userText">
                    <a class="username" dir="auto">Xephiro</a>
                </h3>
                <span class="arrow"></span>
            </div>
        </div>
        <div class="messageInfo primaryContent">
            <div class="messageContent">
                <article>
                    <blockquote class="messageText SelectQuoteContainer ugc baseHtml"> 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<br />
                        <div class="bbCodeBlock bbCodeQuote" data-author="Hatemail">
                            <aside>
                                <div class="attribution type">Hatemail said: <a href="#post-70160" class="AttributionLink">&uarr;</a>
                                </div>
                                <blockquote class="quoteContainer">
                                    <div class="quote">Are you sure my plugin is being loaded first then ptest?</div>
                                    <div class="quoteExpand">Click to expand...</div>
                                </blockquote>
                            </aside>
                        </div>Now its working <img src="{{ '/assets/styles/default/xenforo/clear.png' | prepend: site.baseurl }}" class="mceSmilieSprite mceSmilie7" alt=":p" title="Stick Out Tongue    :p" />, i change the name of method
                        from Test to NewMethod and this work. Next i change again to Test and works again xD<br />
                        <br /> Thanks Hatemail for your help! <div class="messageTextEndMarker">&nbsp;</div>
                    </blockquote>
                </article>
            </div>
            <div class="messageMeta ToggleTriggerAnchor">
                <div class="privateControls">
                    <span class="item muted">
                        <span class="authorEnd"><a class="username author" dir="auto">Xephiro</a>,</span>
                        <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-70161' | prepend: site.baseurl }}" title="Permalink"
                            class="datePermalink"><span class="DateTime" title="Feb 27, 2015 at 2:58 AM">Feb 27, 2015</span></a>
                    </span>
                </div>
                <div class="publicControls">
                    <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-70161' | prepend: site.baseurl }}" title="Permalink"
                        class="item muted postNumber hashPermalink OverlayTrigger" data-href="posts/70161/permalink">#23</a>
                </div>
            </div>
        </div>
    </li>
    <li id="post-73718" class="message" data-author="TheRotAG">
        <div class="messageUserInfo">
            <div class="messageUserBlock">
                <div class="avatarHolder">
                    <span class="helper"></span>
                    <a class="avatar Avm" data-avatarhtml="true"><img src="{{ '/assets/styles/oxide/logo.og.png' | prepend: site.baseurl }}" width="96" height="96" alt="TheRotAG" /></a>
                </div>
                <h3 class="userText">
                    <a class="username" dir="auto">TheRotAG</a>
                </h3>
                <span class="arrow"></span>
            </div>
        </div>
        <div class="messageInfo primaryContent">
            <div class="messageContent">
                <article>
                    <blockquote class="messageText SelectQuoteContainer ugc baseHtml"> Guys,<br /> I&#039;m trying to call the C_Balance function from 00-Economics plugin from Bombardir but no success
                        at all until the moment...<br />
                        <div class="bbCodeBlock bbCodeCode">
                            <div class="type">Code:</div>
                            {% raw %}<pre>
[ChatCommand(&quot;check&quot;)]
        void cmdMoney(BasePlayer player, string command, string[] args)
        {
            var checkMoney = plugins.Find(&quot;00-Economics&quot;);
            var currentPurse = checkMoney.CallHook(&quot;C_Balance&quot;, player, &quot;&quot;);
            Puts(&quot;#################### SUCCESS ####################&quot;);
            SendReply(player, &quot;Current money in the purse: &quot;+currentPurse.ToString());
        }
</pre>{% endraw %}
                        </div>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:<br />
                        <div class="bbCodeBlock bbCodeQuote">
                            <aside>
                                <blockquote class="quoteContainer">
                                    <div class="quote">[Oxide] 8:37 PM [Error] Failed to call hook &#039;C_Balance&#039; on plugin &#039;Economics&#039;<br /> File: 00-Economics.lua Line: 189 attempt
                                        to index local &#039;args&#039; (a nil value):</div>
                                    <div class="quoteExpand">Click to expand...</div>
                                </blockquote>
                            </aside>
                        </div>
                        <div class="messageTextEndMarker">&nbsp;</div>
                    </blockquote>
                </article>
            </div>
            <div class="messageMeta ToggleTriggerAnchor">
                <div class="privateControls">
                    <span class="item muted">
                        <span class="authorEnd"><a class="username author" dir="auto">TheRotAG</a>,</span>
                        <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73718' | prepend: site.baseurl }}" title="Permalink"
                            class="datePermalink"><span class="DateTime" title="Mar 19, 2015 at 11:36 PM">Mar 19, 2015</span></a>
                    </span>
                </div>
                <div class="publicControls">
                    <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73718' | prepend: site.baseurl }}" title="Permalink"
                        class="item muted postNumber hashPermalink OverlayTrigger" data-href="posts/73718/permalink">#24</a>
                </div>
            </div>
        </div>
    </li>
    <li id="post-73719" class="message" data-author="KillParadise">
        <div class="messageUserInfo">
            <div class="messageUserBlock">
                <div class="avatarHolder">
                    <span class="helper"></span>
                    <a class="avatar Avm" data-avatarhtml="true"><img src="{{ '/assets/styles/oxide/logo.og.png' | prepend: site.baseurl }}" width="96" height="96" alt="KillParadise" /></a>
                </div>
                <h3 class="userText">
                    <a class="username" dir="auto">KillParadise</a>
                </h3>
                <span class="arrow"></span>
            </div>
        </div>
        <div class="messageInfo primaryContent">
            <div class="messageContent">
                <article>
                    <blockquote class="messageText SelectQuoteContainer ugc baseHtml">
                        <div class="bbCodeBlock bbCodeQuote" data-author="TheRotAG">
                            <aside>
                                <div class="attribution type">TheRotAG said: <a href="#post-73718" class="AttributionLink">&uarr;</a>
                                </div>
                                <blockquote class="quoteContainer">
                                    <div class="quote">Guys,<br /> I&#039;m trying to call the C_Balance function from 00-Economics plugin from Bombardir but no success at all until the
                                        moment...<br />
                                        <div class="bbCodeBlock bbCodeCode">
                                            <div class="type">Code:</div>
                                            {% raw %}<pre>
[ChatCommand(&quot;check&quot;)]
        void cmdMoney(BasePlayer player, string command, string[] args)
        {
            var checkMoney = plugins.Find(&quot;00-Economics&quot;);
            var currentPurse = checkMoney.CallHook(&quot;C_Balance&quot;, player, &quot;&quot;);
            Puts(&quot;#################### SUCCESS ####################&quot;);
            SendReply(player, &quot;Current money in the purse: &quot;+currentPurse.ToString());
        }
</pre>{% endraw %}
                                        </div>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:
                                    </div>
                                    <div class="quoteExpand">Click to expand...</div>
                                </blockquote>
                            </aside>
                        </div>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. <div
                            class="messageTextEndMarker">&nbsp;</div>
                    </blockquote>
                </article>
            </div>
            <div class="messageMeta ToggleTriggerAnchor">
                <div class="privateControls">
                    <span class="item muted">
                        <span class="authorEnd"><a class="username author" dir="auto">KillParadise</a>,</span>
                        <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73719' | prepend: site.baseurl }}" title="Permalink"
                            class="datePermalink"><span class="DateTime" title="Mar 19, 2015 at 11:39 PM">Mar 19, 2015</span></a>
                    </span>
                </div>
                <div class="publicControls">
                    <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73719' | prepend: site.baseurl }}" title="Permalink"
                        class="item muted postNumber hashPermalink OverlayTrigger" data-href="posts/73719/permalink">#25</a>
                </div>
            </div>
        </div>
    </li>
    <li id="post-73721" class="message" data-author="TheRotAG">
        <div class="messageUserInfo">
            <div class="messageUserBlock">
                <div class="avatarHolder">
                    <span class="helper"></span>
                    <a class="avatar Avm" data-avatarhtml="true"><img src="{{ '/assets/styles/oxide/logo.og.png' | prepend: site.baseurl }}" width="96" height="96" alt="TheRotAG" /></a>
                </div>
                <h3 class="userText">
                    <a class="username" dir="auto">TheRotAG</a>
                </h3>
                <span class="arrow"></span>
            </div>
        </div>
        <div class="messageInfo primaryContent">
            <div class="messageContent">
                <article>
                    <blockquote class="messageText SelectQuoteContainer ugc baseHtml">
                        <div class="bbCodeBlock bbCodeQuote" data-author="KillParadise">
                            <aside>
                                <div class="attribution type">KillParadise said: <a href="#post-73719" class="AttributionLink">&uarr;</a>
                                </div>
                                <blockquote class="quoteContainer">
                                    <div class="quote">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.</div>
                                    <div class="quoteExpand">Click to expand...</div>
                                </blockquote>
                            </aside>
                        </div>So, how would I call C_Balance within other plugin? I tried &quot;*.CallHook(&quot;C_Balance&quot;, player, &quot;PlayerName&quot;)&quot; and
                        &quot;*.CallHook(&quot;C_Balance&quot;, &quot;PlayerName&quot;)&quot; but none worked. <div class="messageTextEndMarker">&nbsp;</div>
                    </blockquote>
                </article>
            </div>
            <div class="messageMeta ToggleTriggerAnchor">
                <div class="privateControls">
                    <span class="item muted">
                        <span class="authorEnd"><a class="username author" dir="auto">TheRotAG</a>,</span>
                        <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73721' | prepend: site.baseurl }}" title="Permalink"
                            class="datePermalink"><span class="DateTime" title="Mar 19, 2015 at 11:47 PM">Mar 19, 2015</span></a>
                    </span>
                </div>
                <div class="publicControls">
                    <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73721' | prepend: site.baseurl }}" title="Permalink"
                        class="item muted postNumber hashPermalink OverlayTrigger" data-href="posts/73721/permalink">#26</a>
                </div>
            </div>
        </div>
    </li>
    <li id="post-73726" class="message" data-author="KillParadise">
        <div class="messageUserInfo">
            <div class="messageUserBlock">
                <div class="avatarHolder">
                    <span class="helper"></span>
                    <a class="avatar Avm" data-avatarhtml="true"><img src="{{ '/assets/styles/oxide/logo.og.png' | prepend: site.baseurl }}" width="96" height="96" alt="KillParadise" /></a>
                </div>
                <h3 class="userText">
                    <a class="username" dir="auto">KillParadise</a>
                </h3>
                <span class="arrow"></span>
            </div>
        </div>
        <div class="messageInfo primaryContent">
            <div class="messageContent">
                <article>
                    <blockquote class="messageText SelectQuoteContainer ugc baseHtml">
                        <div class="bbCodeBlock bbCodeQuote" data-author="TheRotAG">
                            <aside>
                                <div class="attribution type">TheRotAG said: <a href="#post-737" class="AttributionLink">&uarr;</a>
                                </div>
                                <blockquote class="quoteContainer">
                                    <div class="quote">So, how would I call C_Balance within other plugin? I tried &quot;*.CallHook(&quot;C_Balance&quot;, player, &quot;PlayerName&quot;)&quot; and
                                        &quot;*.CallHook(&quot;C_Balance&quot;, &quot;PlayerName&quot;)&quot; but none worked.</div>
                                    <div class="quoteExpand">Click to expand...</div>
                                </blockquote>
                            </aside>
                        </div>I think the main issue is only Lua can use 00-Economics, it only sends back lua tables instead of data. I&#039;ve done the same and ran into the same issue, trying to
                        do<br />
                        <div class="bbCodeBlock bbCodeCode">
                            <div class="type">Code:</div>
                            {% raw %}<pre>
EconomyData = GetEconomy.Call(&quot;GetUserDataFromPlayer&quot;, player);
</pre>{% endraw %}
                        </div>but I don&#039;t get data back only lua tables so I can&#039;t use anything from it.<br /> Since C_Balance takes 3 arguments it would probably be<br />
                        <div class="bbCodeBlock bbCodeCode">
                            <div class="type">Code:</div>
                            {% raw %}<pre>
.Call(&quot;C_Balance&quot;, player, null, &quot;PlayerName&quot;)
</pre>{% endraw %}
                        </div>Edit:<br /> When you send &quot;*.CallHook(&quot;C_Balance&quot;, player, &quot;PlayerName&quot;)&quot; then &quot;PlayerName&quot; fills in the cmd argument slot. Maybe
                        null is an incorrect method or maybe you should send cmd instead of null. <div class="messageTextEndMarker">&nbsp;</div>
                    </blockquote>
                </article>
            </div>
            <div class="messageMeta ToggleTriggerAnchor">
                <div class="privateControls">
                    <span class="item muted">
                        <span class="authorEnd"><a class="username author" dir="auto">KillParadise</a>,</span>
                        <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73726' | prepend: site.baseurl }}" title="Permalink"
                            class="datePermalink"><span class="DateTime" title="Mar 19, 2015 at 11:51 PM">Mar 19, 2015</span></a>
                    </span>
                </div>
                <div class="publicControls">
                    <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73726' | prepend: site.baseurl }}" title="Permalink"
                        class="item muted postNumber hashPermalink OverlayTrigger" data-href="posts/73726/permalink">#27</a>
                </div>
            </div>
        </div>
    </li>
    <li id="post-73739" class="message" data-author="Hatemail">
        <div class="messageUserInfo">
            <div class="messageUserBlock">
                <div class="avatarHolder">
                    <span class="helper"></span>
                    <a class="avatar Avm" data-avatarhtml="true"><img src="{{ '/assets/styles/oxide/logo.og.png' | prepend: site.baseurl }}" width="96" height="96" alt="Hatemail" /></a>
                </div>
                <h3 class="userText">
                    <a class="username" dir="auto">Hatemail</a>
                </h3>
                <span class="arrow"></span>
            </div>
        </div>
        <div class="messageInfo primaryContent">
            <div class="messageContent">
                <article>
                    <blockquote class="messageText SelectQuoteContainer ugc baseHtml"> C_Balance doesn&#039;t return anything so why are you trying to get a return value?<br />
                        <br /> Also the call is just simple: checkMoney.CallHook(&quot;C_Balance&quot;, player, null, args); <div class="messageTextEndMarker">&nbsp;</div>
                    </blockquote>
                </article>
            </div>
            <div class="messageMeta ToggleTriggerAnchor">
                <div class="privateControls">
                    <span class="item muted">
                        <span class="authorEnd"><a class="username author" dir="auto">Hatemail</a>,</span>
                        <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73739' | prepend: site.baseurl }}" title="Permalink"
                            class="datePermalink"><span class="DateTime" title="Mar 20, 2015 at 1:09 AM">Mar 20, 2015</span></a>
                    </span>
                </div>
                <div class="publicControls">
                    <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73739' | prepend: site.baseurl }}" title="Permalink"
                        class="item muted postNumber hashPermalink OverlayTrigger" data-href="posts/73739/permalink">#28</a>
                </div>
            </div>
        </div>
    </li>
    <li id="post-73752" class="message" data-author="KillParadise">
        <div class="messageUserInfo">
            <div class="messageUserBlock">
                <div class="avatarHolder">
                    <span class="helper"></span>
                    <a class="avatar Avm" data-avatarhtml="true"><img src="{{ '/assets/styles/oxide/logo.og.png' | prepend: site.baseurl }}" width="96" height="96" alt="KillParadise" /></a>
                </div>
                <h3 class="userText">
                    <a class="username" dir="auto">KillParadise</a>
                </h3>
                <span class="arrow"></span>
            </div>
        </div>
        <div class="messageInfo primaryContent">
            <div class="messageContent">
                <article>
                    <blockquote class="messageText SelectQuoteContainer ugc baseHtml">
                        <div class="bbCodeBlock bbCodeQuote" data-author="Hatemail">
                            <aside>
                                <div class="attribution type">Hatemail said: <a href="#post-73739" class="AttributionLink">&uarr;</a>
                                </div>
                                <blockquote class="quoteContainer">
                                    <div class="quote">C_Balance doesn&#039;t return anything so why are you trying to get a return value?<br />
                                        <br /> Also the call is just simple: checkMoney.CallHook(&quot;C_Balance&quot;, player, null, args);</div>
                                    <div class="quoteExpand">Click to expand...</div>
                                </blockquote>
                            </aside>
                        </div>Right. I didnt even notice no return.<br /> What about calling GetUserDataFromPlayer, I am using<br />
                        <div class="bbCodeBlock bbCodeCode">
                            <div class="type">Code:</div>
                            {% raw %}<pre>
GetEconomy = plugins.Find('00-Economics') || false;
GetEconomy.Call(&quot;GetUserDataFromPlayer&quot;, player);
</pre>{% endraw %}
                        </div>But I get<br />
                        <div class="bbCodeBlock bbCodeCode">
                            <div class="type">Code:</div>
                            {% raw %}<pre>
[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)
</pre>{% endraw %}
                        </div>back which I am assuming is because I am getting lua tables back from the function... <div class="messageTextEndMarker">&nbsp;</div>
                    </blockquote>
                </article>
            </div>
            <div class="messageMeta ToggleTriggerAnchor">
                <div class="privateControls">
                    <span class="item muted">
                        <span class="authorEnd"><a class="username author" dir="auto">KillParadise</a>,</span>
                        <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73752' | prepend: site.baseurl }}" title="Permalink"
                            class="datePermalink"><span class="DateTime" title="Mar 20, 2015 at 2:05 AM">Mar 20, 2015</span></a>
                    </span>
                </div>
                <div class="publicControls">
                    <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73752' | prepend: site.baseurl }}" title="Permalink"
                        class="item muted postNumber hashPermalink OverlayTrigger" data-href="posts/73752/permalink">#29</a>
                </div>
            </div>
        </div>
    </li>
    <li id="post-73754" class="message" data-author="Hatemail">
        <div class="messageUserInfo">
            <div class="messageUserBlock">
                <div class="avatarHolder">
                    <span class="helper"></span>
                    <a class="avatar Avm" data-avatarhtml="true"><img src="{{ '/assets/styles/oxide/logo.og.png' | prepend: site.baseurl }}" width="96" height="96" alt="Hatemail" /></a>
                </div>
                <h3 class="userText">
                    <a class="username" dir="auto">Hatemail</a>
                </h3>
                <span class="arrow"></span>
            </div>
        </div>
        <div class="messageInfo primaryContent">
            <div class="messageContent">
                <article>
                    <blockquote class="messageText SelectQuoteContainer ugc baseHtml"> GetUserDataFromPlayer isn&#039;t a plugin function...so you can&#039;t call it. <div
                            class="messageTextEndMarker">&nbsp;</div>
                    </blockquote>
                </article>
            </div>
            <div class="messageMeta ToggleTriggerAnchor">
                <div class="privateControls">
                    <span class="item muted">
                        <span class="authorEnd"><a class="username author" dir="auto">Hatemail</a>,</span>
                        <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73754' | prepend: site.baseurl }}" title="Permalink"
                            class="datePermalink"><span class="DateTime" title="Mar 20, 2015 at 2:11 AM">Mar 20, 2015</span></a>
                    </span>
                </div>
                <div class="publicControls">
                    <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73754' | prepend: site.baseurl }}" title="Permalink"
                        class="item muted postNumber hashPermalink OverlayTrigger" data-href="posts/73754/permalink">#30</a>
                </div>
            </div>
        </div>
    </li>
    <li id="post-73755" class="message" data-author="KillParadise">
        <div class="messageUserInfo">
            <div class="messageUserBlock">
                <div class="avatarHolder">
                    <span class="helper"></span>
                    <a class="avatar Avm" data-avatarhtml="true"><img src="{{ '/assets/styles/oxide/logo.og.png' | prepend: site.baseurl }}" width="96" height="96" alt="KillParadise" /></a>
                </div>
                <h3 class="userText">
                    <a class="username" dir="auto">KillParadise</a>
                </h3>
                <span class="arrow"></span>
            </div>
        </div>
        <div class="messageInfo primaryContent">
            <div class="messageContent">
                <article>
                    <blockquote class="messageText SelectQuoteContainer ugc baseHtml">
                        <div class="bbCodeBlock bbCodeQuote" data-author="Hatemail">
                            <aside>
                                <div class="attribution type">Hatemail said: <a href="#post-73754" class="AttributionLink">&uarr;</a>
                                </div>
                                <blockquote class="quoteContainer">
                                    <div class="quote">GetUserDataFromPlayer isn&#039;t a plugin function...so you can&#039;t call it.</div>
                                    <div class="quoteExpand">Click to expand...</div>
                                </blockquote>
                            </aside>
                        </div>I see. So yeah I guess I can&#039;t use economics then lol. Thanks for shedding some light. <div class="messageTextEndMarker">&nbsp;</div>
                    </blockquote>
                </article>
            </div>
            <div class="messageMeta ToggleTriggerAnchor">
                <div class="privateControls">
                    <span class="item muted">
                        <span class="authorEnd"><a class="username author" dir="auto">KillParadise</a>,</span>
                        <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73755' | prepend: site.baseurl }}" title="Permalink"
                            class="datePermalink"><span class="DateTime" title="Mar 20, 2015 at 2:14 AM">Mar 20, 2015</span></a>
                    </span>
                </div>
                <div class="publicControls">
                    <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73755' | prepend: site.baseurl }}" title="Permalink"
                        class="item muted postNumber hashPermalink OverlayTrigger" data-href="posts/73755/permalink">#31</a>
                </div>
            </div>
        </div>
    </li>
    <li id="post-73759" class="message" data-author="Hatemail">
        <div class="messageUserInfo">
            <div class="messageUserBlock">
                <div class="avatarHolder">
                    <span class="helper"></span>
                    <a class="avatar Avm" data-avatarhtml="true"><img src="{{ '/assets/styles/oxide/logo.og.png' | prepend: site.baseurl }}" width="96" height="96" alt="Hatemail" /></a>
                </div>
                <h3 class="userText">
                    <a class="username" dir="auto">Hatemail</a>
                </h3>
                <span class="arrow"></span>
            </div>
        </div>
        <div class="messageInfo primaryContent">
            <div class="messageContent">
                <article>
                    <blockquote class="messageText SelectQuoteContainer ugc baseHtml">
                        <div class="bbCodeBlock bbCodeQuote" data-author="KillParadise">
                            <aside>
                                <div class="attribution type">KillParadise said: <a href="#post-73755" class="AttributionLink">&uarr;</a>
                                </div>
                                <blockquote class="quoteContainer">
                                    <div class="quote">I see. So yeah I guess I can&#039;t use economics then lol. Thanks for shedding some light.</div>
                                    <div class="quoteExpand">Click to expand...</div>
                                </blockquote>
                            </aside>
                        </div>You can call it but it takes a bit of work. <div class="messageTextEndMarker">&nbsp;</div>
                    </blockquote>
                </article>
            </div>
            <div class="messageMeta ToggleTriggerAnchor">
                <div class="privateControls">
                    <span class="item muted">
                        <span class="authorEnd"><a class="username author" dir="auto">Hatemail</a>,</span>
                        <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73759' | prepend: site.baseurl }}" title="Permalink"
                            class="datePermalink"><span class="DateTime" title="Mar 20, 2015 at 3:03 AM">Mar 20, 2015</span></a>
                    </span>
                </div>
                <div class="publicControls">
                    <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73759' | prepend: site.baseurl }}" title="Permalink"
                        class="item muted postNumber hashPermalink OverlayTrigger" data-href="posts/73759/permalink">#32</a>
                </div>
            </div>
        </div>
    </li>
    <li id="post-73760" class="message" data-author="KillParadise">
        <div class="messageUserInfo">
            <div class="messageUserBlock">
                <div class="avatarHolder">
                    <span class="helper"></span>
                    <a class="avatar Avm" data-avatarhtml="true"><img src="{{ '/assets/styles/oxide/logo.og.png' | prepend: site.baseurl }}" width="96" height="96" alt="KillParadise" /></a>
                </div>
                <h3 class="userText">
                    <a class="username" dir="auto">KillParadise</a>
                </h3>
                <span class="arrow"></span>
            </div>
        </div>
        <div class="messageInfo primaryContent">
            <div class="messageContent">
                <article>
                    <blockquote class="messageText SelectQuoteContainer ugc baseHtml">
                        <div class="bbCodeBlock bbCodeQuote" data-author="Hatemail">
                            <aside>
                                <div class="attribution type">Hatemail said: <a href="#post-73759" class="AttributionLink">&uarr;</a>
                                </div>
                                <blockquote class="quoteContainer">
                                    <div class="quote">You can call it but it takes a bit of work.</div>
                                    <div class="quoteExpand">Click to expand...</div>
                                </blockquote>
                            </aside>
                        </div>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. <div
                            class="messageTextEndMarker">&nbsp;</div>
                    </blockquote>
                </article>
            </div>
            <div class="messageMeta ToggleTriggerAnchor">
                <div class="privateControls">
                    <span class="item muted">
                        <span class="authorEnd"><a class="username author" dir="auto">KillParadise</a>,</span>
                        <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73760' | prepend: site.baseurl }}" title="Permalink"
                            class="datePermalink"><span class="DateTime" title="Mar 20, 2015 at 3:05 AM">Mar 20, 2015</span></a>
                    </span>
                </div>
                <div class="publicControls">
                    <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73760' | prepend: site.baseurl }}" title="Permalink"
                        class="item muted postNumber hashPermalink OverlayTrigger" data-href="posts/73760/permalink">#33</a>
                </div>
            </div>
        </div>
    </li>
    <li id="post-73761" class="message" data-author="Hatemail">
        <div class="messageUserInfo">
            <div class="messageUserBlock">
                <div class="avatarHolder">
                    <span class="helper"></span>
                    <a class="avatar Avm" data-avatarhtml="true"><img src="{{ '/assets/styles/oxide/logo.og.png' | prepend: site.baseurl }}" width="96" height="96" alt="Hatemail" /></a>
                </div>
                <h3 class="userText">
                    <a class="username" dir="auto">Hatemail</a>
                </h3>
                <span class="arrow"></span>
            </div>
        </div>
        <div class="messageInfo primaryContent">
            <div class="messageContent">
                <article>
                    <blockquote class="messageText SelectQuoteContainer ugc baseHtml">
                        <div class="bbCodeBlock bbCodeQuote" data-author="KillParadise">
                            <aside>
                                <div class="attribution type">KillParadise said: <a href="#post-73760" class="AttributionLink">&uarr;</a>
                                </div>
                                <blockquote class="quoteContainer">
                                    <div class="quote">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.</div>
                                    <div class="quoteExpand">Click to expand...</div>
                                </blockquote>
                            </aside>
                        </div>Instructions if you want to attempt.<br />
                        <br /> Get a reference to the economics plugin.<br /> Call the GetEconomyAPI function on the stored plugin reference and cast it to a LuaTable.<br /> Loops through all the
                        tables keys and check if its a lua function, store the function you want to call in a variable.<br /> Create an array with the table reference and the ags you want to pass to
                        the function.<br /> Using reflection and the LuaPlugin reference get the Method CallLuaFunction.<br /> Invoke said method passing in the plugin reference, and an array of the
                        function and arguments.<br /> Cast results back accordingly. <div class="messageTextEndMarker">&nbsp;</div>
                    </blockquote>
                </article>
            </div>
            <div class="messageMeta ToggleTriggerAnchor">
                <div class="privateControls">
                    <span class="item muted">
                        <span class="authorEnd"><a class="username author" dir="auto">Hatemail</a>,</span>
                        <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73761' | prepend: site.baseurl }}" title="Permalink"
                            class="datePermalink"><span class="DateTime" title="Mar 20, 2015 at 3:14 AM">Mar 20, 2015</span></a>
                    </span>
                </div>
                <div class="publicControls">
                    <a href="{{ '/threads/run-a-function-from-another-plugin-if-it-doesnt-have-an-api-function.6796/page-2#post-73761' | prepend: site.baseurl }}" title="Permalink"
                        class="item muted postNumber hashPermalink OverlayTrigger" data-href="posts/73761/permalink">#34</a>
                </div>
            </div>
        </div>
    </li>
    <li id="post-73811" class="message" data-author="bawNg">
        <div class="messageUserInfo">
            <div class="messageUserBlock">
                <div class="avatarHolder">
                    <span class="helper"></span>
                    <a class="avatar Avm" data-avatarhtml="true"><img src="{{ '/assets/styles/oxide/logo.og.png' | prepend: site.baseurl }}" width="96" height="96" alt="bawNg" /></a>
                </div>
                <h3 class="userText">
                    <a class="username" dir="auto">bawNg</a>
                </h3>
                <span class="arrow"></span>
            </div>
        </div>
        <div class="messageInfo primaryContent">
            <div class="messageContent">
                <article>
                    <blockquote class="messageText SelectQuoteContainer ugc baseHtml"> 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. <div class="messageTextEndMarker">&nbsp;</div>
                    </blockquote>
           
// ... [Code preview truncated due to length. Full source in attached file] ...

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок
Сверху