schwim
June 27, 2019, 2:04am
1
Hi there everyone,
I need to share a language variable from a framework resource to all the child resources so they know what language to use. I can’t seem to sort out how to do that though.
If I’ve created a var named globalLang, how would I share that with files throughout other resources?
FAXES
June 27, 2019, 2:21am
2
You could use exports. Exports work as a function that can be called from other resources, as long as they are exported. See this:
FiveM supports the general purpose programming language Lua as one of its scripting languages. Lua is a very easy language to learn, simple to use and fast to write. To use Lua, just use .lua in your scripts file extensions.
A modified version of Lua...
schwim
June 27, 2019, 2:29am
3
Thanks for your help, faxes.
If I added this to the server file of the resource with the variable I need to share:
exports("globalLang", function()
return Config.Language
end)
Would I just use something like this to retrieve the var in any other resource, client or server-sided?
language = globalLang
?
FAXES
June 27, 2019, 2:38am
4
See the second link. That one’s for Lua.
schwim
June 27, 2019, 1:04pm
5
I was able to print the statement using the link you provided(thanks!) but I’m having problems passing a variable via that method. Instead of printing in the function, I tried:
exports('globalLocale', function()
globalLanguage = Config.Language
end)
or
globalLanguage = Config.Locale
exports('globalLocale', function()
return globalLanguage
end)
but when I try this to print it in another resource:
exports.framework:globalLocale()
print(globalLanguage)
It prints nil.
How do I retrieve a variable containing my language value from the export?
schwim
June 27, 2019, 2:58pm
6
Got it sorted:
Config.Locale = exports.framework:globalLocale()
1 Like