I have exports functioning – sort of. After I execute the following code 4 times (exactly 4 times, always), I get the error after the code here.
TriggerEvent("chatMessage", $"string is: {Exports["ExportTest"].GetMyString()}", new int[] { 255, 255, 100 });
Exports["ExportTest"].SetMyString();
TriggerEvent("chatMessage", $"NEW string is: {Exports["ExportTest"].GetMyString()}", new int[] { 255, 255, 100 });
The error:
[ 702972] System.InvalidOperationException: Tried to decode invalid MsgPack type 216
[ 702972] at CitizenFX.Core.MsgPackDeserializer.GetUnpacker (System.Byte type) [0x00232] in C:\gl\builds\aaf2d114\0\cfx\fivem\code\client\clrcore\MsgPackDeserializer.cs:387
[ 702987] at CitizenFX.Core.MsgPackDeserializer.UnpackAny (System.IO.BinaryReader reader) [0x00007] in C:\gl\builds\aaf2d114\0\cfx\fivem\code\client\clrcore\MsgPackDeserializer.cs:30
[ 702987] at CitizenFX.Core.MsgPackDeserializer.UnpackArray (System.IO.BinaryReader reader, System.Int32 length) [0x0000a] in C:\gl\builds\aaf2d114\0\cfx\fivem\code\client\clrcore\MsgPackDeserializer.cs:56
[ 702987] at CitizenFX.Core.MsgPackDeserializer.UnpackFixArray (System.Byte a, System.IO.BinaryReader reader) [0x00005] in C:\gl\builds\aaf2d114\0\cfx\fivem\code\client\clrcore\MsgPackDeserializer.cs:217
[ 702987] at CitizenFX.Core.MsgPackDeserializer.UnpackAny (System.IO.BinaryReader reader) [0x0000f] in C:\gl\builds\aaf2d114\0\cfx\fivem\code\client\clrcore\MsgPackDeserializer.cs:32
[ 702987] at CitizenFX.Core.MsgPackDeserializer.Deserialize (System.Byte[] data, System.String netSource) [0x0001b] in C:\gl\builds\aaf2d114\0\cfx\fivem\code\client\clrcore\MsgPackDeserializer.cs:24
[ 702987] at CitizenFX.Core.InternalManager.TriggerEvent (System.String eventName, System.Byte[] argsSerialized, System.String sourceString) [0x00021] in C:\gl\builds\aaf2d114\0\cfx\fivem\code\client\clrcore\InternalManager.cs:194
[ 703003] System.InvalidOperationException: Tried to decode invalid MsgPack type 216
[ 703018] at CitizenFX.Core.MsgPackDeserializer.GetUnpacker (System.Byte type) [0x00232] in C:\gl\builds\aaf2d114\0\cfx\fivem\code\client\clrcore\MsgPackDeserializer.cs:387
[ 703018] at CitizenFX.Core.MsgPackDeserializer.UnpackAny (System.IO.BinaryReader reader) [0x00007] in C:\gl\builds\aaf2d114\0\cfx\fivem\code\client\clrcore\MsgPackDeserializer.cs:30
[ 703018] at CitizenFX.Core.MsgPackDeserializer.UnpackArray (System.IO.BinaryReader reader, System.Int32 length) [0x0000a] in C:\gl\builds\aaf2d114\0\cfx\fivem\code\client\clrcore\MsgPackDeserializer.cs:56
[ 703018] at CitizenFX.Core.MsgPackDeserializer.UnpackFixArray (System.Byte a, System.IO.BinaryReader reader) [0x00005] in C:\gl\builds\aaf2d114\0\cfx\fivem\code\client\clrcore\MsgPackDeserializer.cs:217
[ 703018] at CitizenFX.Core.MsgPackDeserializer.UnpackAny (System.IO.BinaryReader reader) [0x0000f] in C:\gl\builds\aaf2d114\0\cfx\fivem\code\client\clrcore\MsgPackDeserializer.cs:32
[ 703034] at CitizenFX.Core.MsgPackDeserializer.Deserialize (System.Byte[] data, System.String netSource) [0x0001b] in C:\gl\builds\aaf2d114\0\cfx\fivem\code\client\clrcore\MsgPackDeserializer.cs:24
[ 703034] at CitizenFX.Core.InternalManager.TriggerEvent (System.String eventName, System.Byte[] argsSerialized, System.String sourceString) [0x00021] in C:\gl\builds\aaf2d114\0\cfx\fivem\code\client\clrcore\InternalManager.cs:194
[ 703096] Failed to run a tick for BriglairRP: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: `CitizenFX.Core.ExportSet' does not contain a definition for `SetMyString'
[ 703096] at (wrapper dynamic-method) System.Object:CallSite.Target (System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object)
[ 703112] at BriglairRP.BriglairRP+<OnTick>d__29.MoveNext () [0x001e3] in <5b47632a963648579b8af455cf3355bd>:0
[ 703112]
The primary thing I see from this is the following. If I were to run it again, it would then say `GetMyString’ isn’t there.
`CitizenFX.Core.ExportSet' does not contain a definition for `SetMyString'
The code for my exports resource is:
public class ExportTestCL : BaseScript
{
string thisString = "TEST(1)";
public delegate string SimpleDelegate();
public delegate void SimpleDelegate2();
public ExportTestCL()
{
SimpleDelegate simpleDelegate = new SimpleDelegate(GetMyString);
SimpleDelegate2 simpleDelegate2 = new SimpleDelegate2(SetMyString);
Exports.Add("GetMyString", simpleDelegate);
Exports.Add("SetMyString", simpleDelegate2);
}
public string GetMyString()
{
return thisString;
}
public void SetMyString()
{
thisString += " (+)";
}
}