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: Github Repo: GitHub - Purpose-Dev/5m-proto: For use protocol buffers in a fivem environment NPM Registry: 5m-proto - npm Hello FiveM Community ! I’m thrilled to unveil my...
forum.cfx.re
主题: 介绍5m-protobuf:一个用于在 Typescript 或 JavaScript 代码中使用 Procol 缓冲区的小型库
链接:
- Github Repo:GitHub - Purpose-Dev/5m-proto:用于在 fivem 环境中使用协议缓冲区
- NPM 注册表:5m-proto - npm
你好,FiveM 社区!
我很高兴推出我的最新项目:5m-proto- 一个用于在 JavaScript/TypeScript 项目中使用协议缓冲区的小型库。什么是协议缓冲区?
协议缓冲区(通常缩写为 Protobuf)是 Google 开发的用于序列化结构化数据的方法。它用于将数据编码为紧凑的二进制格式,以便通过网络轻松传输或存储,然后解码回可用格式。以下是高级概述- Protobuf 方案示例:
lua:
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;
}