fivem icon indicating copy to clipboard operation
fivem copied to clipboard

[MonoV2] Event listeners with a byte[] as a parameter fail to register

Open ruigouveiamaciel opened this issue 1 year ago • 2 comments

What happened?

Events that take byte arrays as a parameter fail when registering (past build 8380).

public class ExampleServerScript : BaseScript
{
	[EventHandler("exampleEvent", Binding.Remote)]
	private static void HandleIncomingRequest([Source] Player player, byte[] data)
	{
		Debug.WriteLine("Hello World");
	}
}
[rcon/script:Placehol] Registering CitizenFX.Core.EventHandler PlaceholderRP.Server.Hooks.Hooks.HandleIncomingRequest failed with exception: System.ArgumentException: Bad type def, can't handle '>' at 28
[rcon/script:Placehol] Parameter name: typeName
[rcon/script:Placehol]   at System.TypeSpec.Parse (System.String name, System.Int32& p, System.Boolean is_recurse, System.Boolean allow_aqn) [0x004f5] in <fbc4ec45371543bfba3678ebb82caf6d>:0
[rcon/script:Placehol]   at System.TypeSpec.Parse (System.String typeName) [0x00010] in <fbc4ec45371543bfba3678ebb82caf6d>:0
[rcon/script:Placehol]   at System.Reflection.Emit.ModuleBuilder.GetType (System.String className, System.Boolean throwOnError, System.Boolean ignoreCase) [0x00037] in <fbc4ec45371543bfba3678ebb82caf6d>:0
[rcon/script:Placehol]   at System.Reflection.Emit.ModuleBuilder.GetType (System.String className) [0x00000] in <fbc4ec45371543bfba3678ebb82caf6d>:0
[rcon/script:Placehol]   at CitizenFX.MsgPack.Formatters.ArrayFormatter.Build (System.Type type, System.Type typeArray) [0x00016] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\Formatters\ArrayFormatter.cs:17
[rcon/script:Placehol]   at CitizenFX.MsgPack.MsgPackRegistry.CreateSerializer (System.Type type) [0x0002a] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackRegistry.cs:190
[rcon/script:Placehol]   at CitizenFX.MsgPack.MsgPackRegistry.GetOrCreateDeserializer (System.Type type) [0x00000] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackRegistry.cs:174
[rcon/script:Placehol]   at CitizenFX.MsgPack.MsgPackDeserializer.ConstructDelegate (System.Object target, System.Reflection.MethodInfo method) [0x0022b] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackFunc.cs:124
[rcon/script:Placehol]   at CitizenFX.MsgPack.MsgPackDeserializer.CreateDelegate (System.Object target, System.Reflection.MethodInfo method) [0x000a0] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackFunc.cs:39
[rcon/script:Placehol]   at CitizenFX.Core.BaseScript.Initialize () [0x000a4] in C:\gl\builds\cfx-fivem\master\fxserver\code\client\clrcore-v2\BaseScript.cs:97
[rcon/script:Placehol] Instantiated instance of script PlaceholderRP.Server.AdminQOL.AdminCommands.

Expected result

Event should not fail to register

Reproduction steps

  1. Use build 8385 of FxServer

  2. Make a resource that uses MonoV2

  3. Add this script to your resource and watch the server/client fail to register it

public class ExampleServerScript : BaseScript
{
	[EventHandler("exampleEvent", Binding.Remote)]
	private static void HandleIncomingRequest(Player player, byte[] data)
	{
		Debug.WriteLine("Hello World");
	}
}

Importancy

Slight inconvenience

Area(s)

ScRT: C#

Specific version(s)

Server 8380 Windows

Additional information

No response

ruigouveiamaciel avatar Jun 01 '24 22:06 ruigouveiamaciel

Try again on latest build.

FabianTerhorst avatar Jul 12 '24 12:07 FabianTerhorst

This was already solved with the msgpack reverted

DaniGP17 avatar Oct 10 '24 18:10 DaniGP17