karimsqualli96 Posted August 26, 2014 Posted August 26, 2014 hi, in order to create an account system, i want to share a variable over all ressources, i'm not sure but it is possible to do it with using a table that contain all players data and make an external function that return that table, there will be no memory access error?? cause i read that each ressource run on it own space
Anubhav Posted August 26, 2014 Posted August 26, 2014 function exportThisFunction() return variablleName or tableName end See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
Atton Posted August 27, 2014 Posted August 27, 2014 This can be done using exports. viewtopic.php?f=148&t=61058 Nikola Tesla is love Nikola Tesla is light. Email: [email protected]
ixjf Posted August 27, 2014 Posted August 27, 2014 hi, in order to create an account system, i want to share a variable over all ressources, i'm not sure but it is possible to do it with using a table that contain all players data and make an external function that return that table, there will be no memory access error?? cause i read that each ressource run on it own space You can't export functions and coroutines (and most likely userdata too, unless it is recreated in the new Lua state pointing to the same memory address). Other types like number, string and table, however, can be copied. I used to know how to code, but then I took an arrow in the knee. Project Redivivus - Remaking Old School MTA With New Code MTA 0.6 Nightly 1 released
karimsqualli96 Posted August 27, 2014 Author Posted August 27, 2014 Ok, thanks i understand, but why making sharing variable between ressource not supported directly ?? i must make a function to return the address of the table, adding the overhead of function call
myonlake Posted August 27, 2014 Posted August 27, 2014 Ok, thanks i understand, but why making sharing variable between ressource not supported directly ?? i must make a function to return the address of the table, adding the overhead of function call Each resource has their own Lua virtual machine. They don't talk with each other unless forced to. Currently exports are the only and good way to do that. It is like the same thing with modern browsers where each page tab is their own process. Improves safety and many other things. If I helped you, please click the like button on the right Thanks!
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