qbox-framework
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseQbox Framework Development
Qbox框架开发
This skill provides guidelines and patterns for developing resources using the Qbox Project (qbx_core).
本技能为使用**Qbox Project(qbx_core)**开发资源提供指导规范和模式。
1. Philosophy: Exports & Modules
1. 设计理念:导出与模块
Qbox moves away from the global "Core Object" pattern (though supported via bridge) in favor of direct exports and imported modules.
Modern Native Way (Preferred):
lua
local player = exports.qbx_core:GetPlayer(source)Bridge Way (Legacy/Porting):
lua
local QBCore = exports['qb-core']:GetCoreObject() -- Works via qbx_core bridgeQbox摒弃了全局“核心对象”模式(尽管通过桥接仍支持),转而采用直接导出和导入模块的方式。
推荐的现代原生方式:
lua
local player = exports.qbx_core:GetPlayer(source)桥接方式(遗留/移植场景):
lua
local QBCore = exports['qb-core']:GetCoreObject() -- 可通过qbx_core桥接正常工作2. Key Dependencies
2. 关键依赖
Qbox is built "Ox-First". You will frequently use:
- ox_lib: For UI, callbacks, zones, and utilities.
- ox_inventory: For items and inventory management.
- oxmysql: For database interactions.
Qbox采用“Ox优先”的构建理念,你会频繁用到以下工具:
- ox_lib:用于UI、回调、区域管理和工具函数。
- ox_inventory:用于物品和库存管理。
- oxmysql:用于数据库交互。
3. Player Management
3. 玩家管理
- Get Player:
exports.qbx_core:GetPlayer(source) - Player Data: Unlike QBCore's lookup table, Qbox uses internal setters/getters exposed via exports.
- Save/Load: Handled automatically, but custom data can be saved via .
GetPlayer(source).Functions.SetMetaData
- 获取玩家:
exports.qbx_core:GetPlayer(source) - 玩家数据: 不同于QBCore的查找表,Qbox通过导出的内部设置器/获取器来处理玩家数据。
- 保存/加载: 系统会自动处理,但可通过保存自定义数据。
GetPlayer(source).Functions.SetMetaData
4. Resource Structure
4. 资源结构
my-resource/
├── fxmanifest.lua # Depends on qbx_core
├── client/
│ └── main.lua
├── server/
│ └── main.lua
└── locales/ # Ox_lib uses .json locales usually
└── en.jsonmy-resource/
├── fxmanifest.lua # 依赖qbx_core
├── client/
│ └── main.lua
├── server/
│ └── main.lua
└── locales/ # Ox_lib通常使用.json格式的本地化文件
└── en.json5. Documentation
5. 文档
- Official Docs: https://docs.qbox.re/
- Github: https://github.com/Qbox-project/qbx_core