Get data from another C # plugin

salva

Friendly self-taught developer
Administrator
Jan 31, 2016
577
612
63
Can I get the information from plug-in # 1 by plug-in # 2? C#

# 1 plugin on the / kits
# 2 plugin for ranks
You should prepare plugin # 1 with some static method to be able to call the reference in plugin # 2, or something like that
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
Theres 2 main ways to do it (Theres more, But these are the easiest and CPU friendly)
First, DataStore...

This is an example of how I got DonatorRank to change the cooldowns/Max sethome / Tp Delay in DreTaX's HomeSystem with just a simple edit to the HomeSystem plugin.
First, Created a method in the HomeSystem plugin : HomeSystem.py
Then I can change the values in my plugin (DonatorRank) : DonatorRank.cs
Really depends on the plugin/s you need to get information from. I'm not too sure if the Kits plugin saves the kit info in the DataStore (Make a method to save kits data in DataStore?) but if it did then you can retrieve that info without editing the plugin.

Second, Calling /Getting methods and Values using GlobalPluginCollector.
For example if I wanted to get the rank of a player from DonatorRank I would need to call the CheckPerm function : DonatorRank.cs

Example of how to get the Rank:
C#:
object donatorrank = GlobalPluginCollector.GetPluginCollector().GetPlugin("DonatorRank");
if (donatorrank != null)
{
    player.Message("Found plugin!");
    string rank = "Default";
    try
    {
        rank = donatorrank.Invoke("CheckPerm", "INSERT PLAYERS HARDWARE ID HERE" + ":Rank");
    }
    catch
    {
        player.Message("Could not Invoke method");
    }
    player.Message("Your rank is: " + rank);
}
else
{
    player.Message("Can not find plugin!");
}
The Invoke method is found in the Plugin Class: http://fougerite.com/wiki/plugin/ (Not Complete)
Python = IronPython.Deps.dll
LUA = MoonSharp.Interpreter.dll
Magma (JavaScript) = Jint.dll
CSharp = ??? @DreTaX
If the invoke method is throwing errors then check the plugin class for CSharp but I have no idea what module that is hiding in, DreTaX may be able to point you in the direction for that dll
 
Last edited:

salva

Friendly self-taught developer
Administrator
Jan 31, 2016
577
612
63
Theres 2 main ways to do it (Theres more, But these are the easiest and CPU friendly)
First, DataStore...

This is an example of how I got DonatorRank to change the cooldowns/Max sethome / Tp Delay in DreTaX's HomeSystem with just a simple edit to the HomeSystem plugin.
First, Created a method in the HomeSystem plugin : HomeSystem.py
Then I can change the values in my plugin (DonatorRank) : DonatorRank.cs
Really depends on the plugin/s you need to get information from. I'm not too sure if the Kits plugin saves the kit info in the DataStore (Make a method to save kits data in DataStore?) but if it did then you can retrieve that info without editing the plugin.

Second, Calling /Getting methods and Values using GlobalPluginCollector.
For example if I wanted to get the rank of a player from DonatorRank I would need to call the CheckPerm function : DonatorRank.cs

Example of how to get the Rank:
C#:
object donatorrank = GlobalPluginCollector.GetPluginCollector().GetPlugin("DonatorRank");
if (donatorrank != null)
{
    player.Message("Found plugin!");
    string rank = "Default";
    try
    {
        rank = donatorrank.Invoke("CheckPerm", "INSERT PLAYERS HARDWARE ID HERE" + ":Rank");
    }
    catch
    {
        player.Message("Could not Invoke method");
    }
    player.Message("Your rank is: " + rank);
}
else
{
    player.Message("Can not find plugin!");
}
The Invoke method is found in the Plugin Class: http://fougerite.com/wiki/plugin/ (Not Complete)
Python = IronPython.Deps.dll
LUA = MoonSharp.Interpreter.dll
Magma (JavaScript) = Jint.dll
CSharp = ??? @DreTaX
If the invoke method is throwing errors then check the plugin class for CSharp but I have no idea what module that is hiding in, DreTaX may be able to point you in the direction for that dll
Great answer Jakkee, greetings