FxEvents.RedM.Client 2.5.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package FxEvents.RedM.Client --version 2.5.1                
NuGet\Install-Package FxEvents.RedM.Client -Version 2.5.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FxEvents.RedM.Client" Version="2.5.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FxEvents.RedM.Client --version 2.5.1                
#r "nuget: FxEvents.RedM.Client, 2.5.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FxEvents.RedM.Client as a Cake Addin
#addin nuget:?package=FxEvents.RedM.Client&version=2.5.1

// Install FxEvents.RedM.Client as a Cake Tool
#tool nuget:?package=FxEvents.RedM.Client&version=2.5.1                

FxEvents an advanced event subsystem for FiveM

With FxEvents you can send and get values between client and server using an advanced event handling process. Signatures are encrypted per each client and using the proviced MsgPack binary serialization you can hide contents from malicious clients! To work you only need to add FXEvents.Client.dll or FXEvents.Server.dll and Newtonsoft.Json.dll (In case of json serialization) to your resource. No need of any external library for MsgPack, the event system uses the internal MsgPack dll provided with fivem itself!!

Discord Server Invite

Usage examples:

Initialization

public class Main : BaseScript
{
 public Main()
 {
  // The Event Dispatcher can now be initialized with your own inbound, outbound, and signatures.
  // This allows you to use FxEvents in more than one resource on the server without having signature collisions.
  EventDispatcher.Initalize("inbound", "outbound", "signature");
 }
}

To mount an event:

EventDispatcher.Mount("eventName", new Action<ISource, type1, type2>(([FromSource] source, val1, val2) =>    
{
  // code to be used inside the event.
  // ISource is the optional insider class that handles clients triggering the event.. is like the "[FromSource] Player player" parameter but can be derived and handled as you want!!
  // Clientside is the same thing without the ClientId parameter
}));

To trigger an event

The library only works in client ←-> server communication.. for the moment same side events are not working but the feature will be added in the future!

// clientside
EventDispatcher.Send("eventName", params);

// serverside
EventDispatcher.Send(Player, "eventName", params);
EventDispatcher.Send(List<Player>, "eventName", params);
EventDispatcher.Send(ISource, "eventName", params);
EventDispatcher.Send(List<ISource>, "eventName", params);

To trigger a callback

Mounting it

EventDispatcher.Mount("eventName", new Func<ISource, type1, type2, Task<returnType>>(async ([FromSource] source, val1, val2) =>    
{
  // code to be used inside the event.
  // ISource is the optional insider class that handles clients triggering the event.. is like the "[FromSource] Player player" parameter but can be derived and handled as you want!!
  // Clientside is the same thing without the ISource parameter
  return val3
}));

Calling it

// clientside
type param = await EventDispatcher.Get<type>("eventName", params);

// serverside
type param = await EventDispatcher.Get<type>(ClientId, "eventName", params);
type param = await EventDispatcher.Get<type>(Player, "eventName", params);

Callbacks can be called serverside too because it might happen that the server needs info from certain clients and this will help you doing it.

The library comes with some goodies to help with customization and debugging serialization printing.

ToJson()

image

⚠️ You need Newtonsoft.Json to make this work!!

string text = param.ToJson();

FromJson()

⚠️ You need Newtonsoft.Json to make this work!!

type value = jsonText.FromJson<type>();

ToBytes()

image

byte[] bytes = param.ToBytes();

FromBytes()

type value = bytes.FromBytes<type>();

BytesToString

byte[] bytes = param.ToBytes();
string txt = bytes.BytesToString();

StringToBytes

byte[] bytes = txt.StringToBytes();
type value = bytes.FromBytes<type>();
Product Compatible and additional computed target framework versions.
.NET Framework net452 is compatible.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.1 123 7/7/2024
2.9.1 129 4/8/2024
2.9.0 127 4/5/2024 2.9.0 is deprecated because it has critical bugs.
2.8.4 122 4/4/2024
2.6.1-tags-v2-7-3.1 50 4/4/2024
2.6.0 198 12/21/2023
2.5.1 174 11/8/2023
2.5.1-beta0 112 11/8/2023
2.5.0 155 9/29/2023
1.0.3 196 4/24/2023
1.0.2 290 12/24/2022
1.0.1 299 12/22/2022
1.0.0 442 12/22/2022 1.0.0 is deprecated because it has critical bugs.