const Wait = async function(ms) { return new Promise((resolve, reject) => { setTimeout(() => { return resolve(true) }, ms) }) } async function GetFrameworkObject(config) { let object = null; if (config.Framework === "oldesx") { let counter = 0; while (!object) { emit('esx:getSharedObject', function(obj) { object = obj; }); counter += 1; if (counter === 3) { break; } await Wait(1000); } if (!object) { console.log( "codem-adminpanel:Framework is not selected in the config correctly if you're sure it's correct please check your events to get framework object"); } } if (config.Framework === "esx") { let counter = 0; let status = false; try { exports['es_extended'].getSharedObject(); status = true; } catch (e) {} if (status) { while (!object) { object = exports['es_extended'].getSharedObject(); counter += 1; if (counter === 3) { break; } await Wait(1000); } } if (!object) { console.log( "codem-adminpanel:Framework is not selected in the config correctly if you're sure it's correct please check your events to get framework object"); } } if (config.Framework === "qb") { let counter = 0; let status = false; try { exports["qb-core"].GetCoreObject(); status = true; } catch (e) {} if (status) { while (!object) { object = exports["qb-core"].GetCoreObject(); counter += 1; if (counter === 3) { break; } await Wait(1000); } } if (!object) { console.log( "codem-adminpanel:Framework is not selected in the config correctly if you're sure it's correct please check your events to get framework object"); } } if (config.Framework === "oldqb") { let counter = 0; while (!object) { counter += 1; emit('QBCore:GetObject', function(obj) { object = obj; }); if (counter === 3) { break; } await Wait(1000); } if (!object) { console.log( "codem-adminpanel:Framework is not selected in the config correctly if you're sure it's correct please check your events to get framework object"); } } return object; }