Curious how other people handle multi-framework support in a single resource. The three approaches I see most:
A small bridge file per framework (bridge/esx.lua, bridge/qb.lua, bridge/qbox.lua) that exposes the same few functions: GetPlayer, AddMoney, RemoveMoney, HasItem, Notify. The rest of the resource only calls those. Clean, but every framework update means checking all three files.
Lean on ox_lib / ox_inventory for the shared stuff and only bridge the player and money part. Less code, but now the resource hard-depends on ox.
Separate branches per framework. Easiest to read, hardest to maintain, since a fix in one branch is easy to forget in the others.
Qbox is the tricky one. It’s close enough to QBCore that most things work through the qb export, until something like job/gang data or item metadata doesn’t, and that tends to show up late.
How are you structuring it? Bridge files, one framework only, or something else? And if you use bridge files, do you detect the framework automatically with GetResourceState or make the server owner set it in config?
I’ve been running a Qbox server and the thing that saved me was keeping each framework’s bridge in its own tiny file, like 50 lines each, and letting ox_lib handle the shared UI and notifications. That way if Qbox updates something I only touch one file. Did you end up going with a single abstraction layer or separate entry points per framework?
I would go with the bridge-file approach too, with one thin interface like GetPlayer, AddMoney, RemoveMoney, HasItem and Notify, and let each bridge file translate that into ESX, QBCore or Qbox calls. Auto-detecting the framework with GetResourceState keeps it simple for server owners, but I would still allow a config override for cases where both ESX and QBCore resources happen to be installed. Qbox is the one to watch, since job and gang data and item metadata do not always behave the same as QBCore even though the exports look similar.
Yeah, that’s the setup I keep coming back to. One thing I’d add: do the GetResourceState check once at startup and cache the bridge, instead of checking on every call. I’d also fail loudly if no framework is found, so you don’t end up with nil errors halfway through a transaction.