From 5db9e88bb94e28b50bfe80f9e707a17d46cd9bce Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Sat, 7 Jun 2025 18:13:06 +0100 Subject: [PATCH] add function checkExportExists() Workaround function made to detect if new QB Inventory functions are available This can be used in other situations like checking if a script is working correctly or not and the export has been registered --- shared/helpers.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/shared/helpers.lua b/shared/helpers.lua index d5cb6b7..e332138 100644 --- a/shared/helpers.lua +++ b/shared/helpers.lua @@ -56,6 +56,25 @@ function isServer() return IsDuplicityVersion() end +function checkExportExists(resource, export) + if not resource or not export then return false end + + local exists = false + local ok, result = pcall(function() + exists = type(exports[resource][export]) == "function" + end) + + if ok and exists then + debugPrint(("^3Export Check^7: ^5exports^7['^5%s^7']:^5%s^7() ^2Exists^7"):format(resource, export)) + return true + else + debugPrint(("^3Export Check^7: ^5exports^7['^5%s^7']:^5%s^7() ^1Doesn^7'^1t Exist^7"):format(resource, export)) + return false + end +end + + + ------------------------------------------------------------- -- Debugging and JSON Utilities -------------------------------------------------------------