fivem-docs icon indicating copy to clipboard operation
fivem-docs copied to clipboard

docs(developers): add documentation for MessagePack

Open JustGodWork opened this issue 1 year ago • 0 comments

This pull request introduces comprehensive documentation for the MessagePack integration in FiveM, detailing its features, reserved types, and usage in Lua and JavaScript runtimes. The C# section is marked as TODO to allow future contributions.

This documentation complements citizenfx/fivem#2931, which globally exposes the MessagePack codec (msgpack_pack and msgpack_unpack) to enhance cross-runtime data serialization and deserialization.

Key Updates:

  • MessagePack Overview:

    • Introduction to the binary serialization format and its support across Lua, JavaScript, and C#.
    • Features like compact serialization and cross-language compatibility.
  • Reserved Extension Types: A table of FiveM-specific types, such as Vector2, Vector3, and others.

  • Lua API:

    • Documentation for built-in functions (msgpack.pack, msgpack.pack_args, msgpack.unpack) with practical examples.
    • Guide to adding custom types for serialization.
  • JavaScript API:

    • Explanation of global codec functions (msgpack_pack, msgpack_unpack) and custom codec usage.
    • Examples of encoding, decoding, and extending types.
  • Example Scenarios: Real-world cases of cross-runtime data handling (Lua to JavaScript, JavaScript to C#, and C# to Lua).

Reason for the Update:

This documentation supports the recent enhancement from citizenfx/fivem#2931, ensuring developers can effectively utilize the MessagePack codec for optimized data handling across all FiveM-supported runtimes. Preview:

The document is located at content/docs/scripting-reference/msgpack.md.

Feedback Requested:

  • Suggestions for improving clarity or adding examples.
  • Contributions to the C# API section.

JustGodWork avatar Nov 18 '24 17:11 JustGodWork