Make your mods Work with ANY framework

I’ve noticed a lot more framework specific mods get copycatted over to other frameworks if there isnt already a clone of the script they need… ( usually poorly adapted )
Devs, we can stop this easily by adding in code that caters to MULTIPLE frameworks.
This is how i’ve been doing it…

if(GetResourceState('qb-core')=="started"){
 /// do qbcore things here...
}
else if(GetResourceState('es_extended')=="started"){
 // do esx things
}
else{ 
 //  do standalone or "non standard" framework here.
}

It’s a couple lines of extra work, that guarantees larger audience and less plagiarism.
Hopefully this lets you make code that will run in any framework.

If you know of a better way to include all frameworks without a massive headache, i’d love to hear it.
Just thought this might be helpful for some.
Enjoy!

1 Like

Another neat little trick to get the respective core variables:
(lua example, but you get the point)

local ESX = nil
local QBCore = nil
if (GetResourceState("es_extended") == "started") then
	ESX = exports["es_extended"]:getSharedObject()
elseif (GetResourceState("qb-core") == "started") then
	QBCore = exports["qb-core"]:GetCoreObject()
end

And then inside your code, you can literally just do this:

if (ESX) then
	-- ESX stuff
elseif (QBCore) then
	-- QB stuff
else
	-- whatever else
end

This also ensures that you are not constantly calling GetResourceState every single time.

2 Likes

Oh thats classy, i hadnt thought to do that yet.
i’ll be updating MY code to add that for sure. :smiley:

1 Like