Last active
July 26, 2022 11:05
-
-
Save grdlo/04a945c5144a4f4ac5c19ce1728f0bb8 to your computer and use it in GitHub Desktop.
Custom import file for FiveM script. More information the first comment: https://gist.github.com/grdlo/04a945c5144a4f4ac5c19ce1728f0bb8?permalink_comment_id=4244975#gistcomment-4244975
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
--- This file is free to use anywhere. | |
--- You can use, edit, and distribuate this files as long as | |
--- the header credits is keep intact or at least with the current info | |
--- | |
--- @author https://github.com/grdlo | |
--- @repository https://gist.github.com/grdlo/04a945c5144a4f4ac5c19ce1728f0bb8 | |
--- @version 1.0.0 | |
--- | |
local scriptname = "<YourScriptNameHere>" | |
local library = { | |
server = { | |
"<YourFileToImport>" | |
}, | |
shared = { | |
"<YourFileToImport>" | |
}, | |
client = { | |
"<YourFileToImport>" | |
} | |
} | |
local function import(file) | |
load(LoadResourceFile(scriptname, file))() | |
end | |
local function foreach(filesArray, func) | |
for k, v in pairs(filesArray or {}) do func(v) end | |
end | |
(function() | |
foreach(library.shared, import) | |
if IsDuplicityVersion() then | |
foreach(library.server, import) | |
else | |
foreach(library.client, import) | |
end | |
end)() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use-it ?
1- Copy the fximport.lua file into the root directory of your script (this is the same folder of your fxmanifest.lua)
2- Open the fximport.lua file and edit the following variables :
scriptname
: define a string here holding the current name of the script (wich will work as a library)library.server
: define an indexed array here holding the clients files to be loadedlibrary.shared
: define an indexed array here holding the clients files to be loadedlibrary.client
: define an indexed array here holding the clients files to be loadedYou can now load you Library Script in other script by adding the following line in the shared_scripts configuration method of the fxmanifest :
The fxmanifest.lua should look like something similar to that:
If this gist was useful to you, don't forget the star