Release a small library for work with protocol buffers in game environment

Subject: Introducing 5m-protobuf: A small library for using procol buffers in typescript or javascript code


Links:


Hello FiveM Community !

I’m thrilled to unveil my latest project: 5m-proto – a small library for work with protocol buffers in JavaScript/TypeScript projects.


What is a Protocol Buffer ?

Protocol Buffers, often abbreviated as Protobuf, is a method developed by Google for serializing structured data. It’s used to encode data into a compact binary format that can be easily transmitted over networks or stored, and then decoded back into a usable form. Here’s a high-level overview

  • Example Protobuf scheme :
syntax = "proto3";

package fivem;

message Position {
  float x = 1;
  float y = 2;
  float z = 3;
}

message Vehicle {
  string model = 1;
  string plate = 2;
  Position position = 3;
  bool is_owned = 4;
}

message WeaponAccessory {
  string name = 1;
}

message Weapon {
  string name = 1;
  int32 ammo_count = 2;
  repeated WeaponAccessory accessories = 3;
}

message Player {
  int32 id = 1;
  string name = 2;
  Position position = 3;
  int32 health = 4;
  int32 armor = 5;
  float cash = 6;
  float bank = 7;
  string job = 8;
  repeated Weapon weapon = 9;
  Vehicle current_vehicle = 10;
}

And protobuf is Efficient and Compact because Protobuf is designed to be compact and efficient, making it suitable for scenarios where performance and bandwidth are critical. The binary format is more efficient in terms of size and speed compared to text-based formats like JSON or XML

4 Likes