Open
Description
What happened?
It's not possible to pass entity as argument to event/export in C#
Expected result
It should be possible
Reproduction steps
- Create export
using System;
using CitizenFX.Core;
namespace ElementData.Client
{
public class ClientMain : BaseScript
{
public ClientMain()
{
Exports.Add("DebugExport", new Func<Player, bool>(DebugExport));
}
public bool DebugExport(Player player)
{
return true;
}
}
}
- Try calling this export
using CitizenFX.Core;
namespace Core.Client
{
public class ClientMain : BaseScript
{
public ClientMain()
{
Exports["YourResourceName"].DebugExport(Game.Player);
}
}
}
- Look into the console
Importancy
Unknown
Area(s)
FiveM, ScRT: C#
Specific version(s)
FXServer-master SERVER v1.0.0.13079 win32
Additional information
Error:
at CitizenFX.Core.MsgPackSerializer.Serialize (System.Object obj, MsgPack.Packer packer) [0x001d2] in C:\gl\builds\cfx-fivem-1\code\client\clrcore\MsgPackSerializer.cs:120
at CitizenFX.Core.MsgPackSerializer.Serialize (System.Object obj) [0x00020] in C:\gl\builds\cfx-fivem-1\code\client\clrcore\MsgPackSerializer.cs:56
at CitizenFX.Core.MsgPackDeserializer+<>c__DisplayClass36_0.<CreateRemoteFunctionReference>b__0 (System.Object[] args) [0x00000] in C:\gl\builds\cfx-fivem-1\code\client\clrcore\MsgPackDeserializer.cs:265
at (wrapper dynamic-method) System.Object:CallSite.Target (System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object,object[])
at (wrapper dynamic-method) System.Object:CallSite.Target (System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object,object[])
at CitizenFX.Core.ExportSet.TryInvokeMember (System.Dynamic.InvokeMemberBinder binder, System.Object[] args, System.Object& result) [0x000f1] in C:\gl\builds\cfx-fivem-1\code\client\clrcore\ExportDictionary.cs:64
at (wrapper dynamic-method) System.Object:CallSite.Target (System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object,CitizenFX.Core.Player,string,int)
at (wrapper dynamic-method) System.Object:CallSite.Target (System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object,CitizenFX.Core.Player,string,int)
at Core.Client.ClientMain..ctor () [0x0001d] in C:\Users\libxx\Desktop\fivem\resources-dev\Core\Client\ClientMain.cs:16
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in <b575c7ac070e41ffa0751333b6ac9f42>:0
--- End of inner exception stack trace ---
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00014] in <b575c7ac070e41ffa0751333b6ac9f42>:0
at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) [0x000a8] in <b575c7ac070e41ffa0751333b6ac9f42>:0
at System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00009] in <b575c7ac070e41ffa0751333b6ac9f42>:0
at System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00027] in <b575c7ac070e41ffa0751333b6ac9f42>:0
at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00020] in <b575c7ac070e41ffa0751333b6ac9f42>:0
at System.Activator.CreateInstance (System.Type type) [0x00000] in <b575c7ac070e41ffa0751333b6ac9f42>:0
at CitizenFX.Core.InternalManager.CreateAssemblyInternal (System.String assemblyFile, System.Byte[] assemblyData, System.Byte[] symbolData) [0x000c4] in C:\gl\builds\cfx-fivem-1\code\client\clrcore\InternalManager.cs:156
Instantiated instance of script Core.Client.Players.SpawnManager.
Registering Tick for attributed method OnPlayerDead
Registering EventHandler core:spawnPlayer for attributed method OnSpawnPlayer, with parameters System.RuntimeType, System.RuntimeType
Looking into FiveM code looks like it tries to serialize a List, and object is clearly NOT a list:
https://github.com/citizenfx/fivem/blob/master/code/client/clrcore/MsgPackSerializer.cs#L120