diff --git a/lua/fxmanifest.lua b/lua/fxmanifest.lua index b49abd7..22b7f6e 100644 --- a/lua/fxmanifest.lua +++ b/lua/fxmanifest.lua @@ -3,13 +3,14 @@ game 'common' name 'oxmysql' description 'Database wrapper for FiveM utilising node-mysql2 offering improved performance and security.' -version '1.8.3' +version '1.8.4' url 'https://github.com/overextended/oxmysql' author 'overextended' use_fxv2_oal 'yes' lua54 'yes' server_scripts { +-- '/server:4837', Disabled until the heat death of the universe (or recommended artifact updates) 'oxmysql.js', 'wrapper.lua' } diff --git a/lua/wrapper.lua b/lua/wrapper.lua index 263070f..f5348bf 100644 --- a/lua/wrapper.lua +++ b/lua/wrapper.lua @@ -28,8 +28,9 @@ CreateThread(function() end, 'GET') end) --- Check for a recent native since the recommended artifact doesn't support JS async_retval or dependency constraints -if not GetEntityAttachedTo then +-- Check for the existance of a native from FXServer 4837 to disable Lua exports +-- Shame dependency constraints were added immediately after the recommended build +if not MumbleSetPlayerMuted then ---@param query string ---@param parameters? table diff --git a/src/index.js b/src/index.js index 892d835..2975fed 100644 --- a/src/index.js +++ b/src/index.js @@ -52,45 +52,51 @@ global.exports('prepare', (query, parameters, cb, resource = GetInvokingResource preparedStatement(query, parameters, resource).then((result) => safeCallback(cb || parameters, result)); }); -// Check for a recent native (~server artifact 4700) to enable JS exports -if (GetEntityAttachedTo !== undefined || !GetResourceMetadata(GetCurrentResourceName(), 'server_script', 1)) { - global.exports('prepareSync', async (query, parameters) => { - const result = await preparedStatement(query, parameters, GetInvokingResource()); - return result; - }); - - global.exports('executeSync', async (query, parameters) => { - const result = await execute(query, parameters, GetInvokingResource()); - return result; - }); - - global.exports('insertSync', async (query, parameters) => { - const result = await execute(query, parameters, GetInvokingResource()); - return result && result.insertId; - }); - - global.exports('updateSync', async (query, parameters) => { - const result = await execute(query, parameters, GetInvokingResource()); - return result && result.affectedRows; - }); - - global.exports('fetchSync', async (query, parameters) => { - const result = await execute(query, parameters, GetInvokingResource()); - return result; - }); - - global.exports('singleSync', async (query, parameters) => { - const result = await execute(query, parameters, GetInvokingResource()); - return result && result[0]; - }); - - global.exports('scalarSync', async (query, parameters) => { - const result = await execute(query, parameters, GetInvokingResource()); - return result && result[0] && Object.values(result[0])[0]; - }); - - global.exports('transactionSync', async (queries, parameters) => { - const result = await transaction(queries, parameters, GetInvokingResource()); - return result; - }); -} +try { + // Check for the existance of a native from FXServer 4837 to enable JS exports + if (MumbleSetPlayerMuted || !GetResourceMetadata(GetCurrentResourceName(), 'server_script', 1)) { + global.exports('prepareSync', async (query, parameters) => { + const result = await preparedStatement(query, parameters, GetInvokingResource()); + return result; + }); + + global.exports('executeSync', async (query, parameters) => { + const result = await execute(query, parameters, GetInvokingResource()); + return result; + }); + + global.exports('insertSync', async (query, parameters) => { + const result = await execute(query, parameters, GetInvokingResource()); + return result && result.insertId; + }); + + global.exports('updateSync', async (query, parameters) => { + const result = await execute(query, parameters, GetInvokingResource()); + return result && result.affectedRows; + }); + + global.exports('fetchSync', async (query, parameters) => { + const result = await execute(query, parameters, GetInvokingResource()); + return result; + }); + + global.exports('singleSync', async (query, parameters) => { + const result = await execute(query, parameters, GetInvokingResource()); + return result && result[0]; + }); + + global.exports('scalarSync', async (query, parameters) => { + const result = await execute(query, parameters, GetInvokingResource()); + return result && result[0] && Object.values(result[0])[0]; + }); + + global.exports('transactionSync', async (queries, parameters) => { + const result = await transaction(queries, parameters, GetInvokingResource()); + return result; + }); + } +} catch(e) { + setTimeout(() => { + console.log(`^3Unable to load enhanced sync exports (download FXServer 4837+)^0`); + }, 1000) +} \ No newline at end of file