SparkzZ Posted September 5, 2016 Share Posted September 5, 2016 (edited) I have a script that contains 2 client files, let's assume they are called scriptClient1.lua and scriptClient2.lua I created a function in scriptClient2.lua and want to use this function in scriptClient1.lua without exporting it in the meta.. is that possible ? and how ? Edited September 5, 2016 by SparkzZ Link to comment
aka Blue Posted September 5, 2016 Share Posted September 5, 2016 You can do it, only if the other script is in the same meta.xml Link to comment
SparkzZ Posted September 5, 2016 Author Share Posted September 5, 2016 (edited) Ah, thanks Edited September 5, 2016 by SparkzZ Link to comment
aka Blue Posted September 5, 2016 Share Posted September 5, 2016 No problem. If you want to use it in another script that is not defined in your scriptClient2.lua meta, you should use export: <export function="functionName" type="client"/> Hope you understand Link to comment
EstrategiaGTA Posted September 5, 2016 Share Posted September 5, 2016 You can do it, of course. As long as the script files are in the same resource you won't need to export them but make sure you are using the function in the same side (client or server) Link to comment
Walid Posted September 5, 2016 Share Posted September 5, 2016 If it's not local function and is on the same side then yes you can call it. same thing with variables because every lua file in a resource is a code block, that can have it's local (variables/functions). if it's not local in this code block it become accessible in other lua files in the same resource. Note: local variables have a scope limited to the block where they are declared so outside of that block they are either nil or have some other value if defined. local function test() -- local function local variable = "Hello" -- local variable function test() -- Global function variable = "Hello" -- Global variable Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now