Require a file from any of your resources
Last updated 1 month ago
If you use the require function in client side you must set the file you require in your fxmanifest as part of the files. Example: files { 'file.lua' }
files { 'file.lua' }
-- The loaded file return { testFunc = function() print('test') end }
-- Manifest file fx_version 'cerulean' lua54 'yes' game 'gta5' shared_script '@HRLib/import.lua' client_script 'client.lua' file 'test.lua'
-- Client side script local testFunctions = HRLib.require(('@%s/test.lua'):format(GetCurrentResourceName())) HRLib.RegCommand('test', function() testFunctions.testFunc() -- Output: test end)
path
string
Format: '@resourceName/folder/file.lua'
----