Hello,
So, I have two scripts. One called “quostix” which is essentially the framework, and another “quostix-vehicles” that needs to access data and functions from “quostix”.
I have all player information loaded into a dictionary that is stored in “quostix”:
public static Dictionary<string, Obj> LoadedPlayers = new Dictionary<string, Obj>();
- This all works completely fine within “quostix” but the problem arises when I try to export to “quostix-vehicles”.
public class Obj
{
public string Handle { get; set; }
public string Identifier { get; set; }
public string Group { get; set; }
public CharacterObj Character { get; set; }
public StatusObj Status { get; set; }
public Dictionary<string, ItemObj> Inventory { get; set; }
public LicensesObj Licenses { get; set; }
// I have removed the other classes etc to shorten the post.
// So this works and the data is accessiable.
// But I also have these:
internal Func<dynamic> GetInventory;
internal Func<string, dynamic> GetInventoryItem;
internal Func<string, dynamic> GetInventoryItemSlot;
internal Func<string> FindEmptySlot;
internal Action<string, int, dynamic, double, string> AddInventoryItem;
internal Action<string, int, string> RemoveInventoryItem;
internal Func<int> GetCash;
internal Action<int> AddCash;
internal Action<int> RemoveCash;
internal Func<string, bool> CheckLicense;
internal Action<string, bool> UpdateLicense;
}
If I try and access these functions within “quostix”, they work, but they don’t exist upon export, example:
try
{
dynamic playerObj = Exports["quostix"].GetPlayerObj(player.Handle);
string type = data.Payment;
int bank = playerObj.Character.Bank.Balance; // <- This works.
int cash = playerObj.GetCash(); // <- This does not work.
// This also causes the exception to throw because "GetCash" does not exist
// in the export despite it working inside "quostix".
}
catch (Exception ex)
{
Debug.WriteLine($"[^2quostix-vehicles^7] [^1ERROR^7] {ex.Message}");
}
I’m clearly doing something wrong but I’m unsure as to what. I have tried adding “quostix” as a reference in “quostix-vehicles” but this creates another instance and then everything happens multiple times.
- Why do these Func/Actions not export?
- What can I do to fix my code to solve this issue? Am I exporting wrong or am I doing it in the completely wrong way?
My one solution was to turn all of the Func/Actions into exports and access them via:
Exports["quostix"].GetCash(player.Handle);
But I’m not sure if this is a “bodged” way of doing it.
Help would be appreciated.
Quostix.