iPanda Posted September 28, 2014 Posted September 28, 2014 Good day guys. I had a no problem, but rather a question. I've been working with Lua, but with a not yet encountered. Does not work saving a date element if its value is worth in braces "{}" That's actually made an example for you to understand: --"elementData" value is {2,0.1,0.3,0.8,0.9} -- -- --EXAMPLE: setElementData(source,"elementData",{2,0.1,0.3,0.8,0.9}) playerData = {{"elementData"}} addEventHandler("onPlayerLogin",root,function() account = getPlayerAccount(source) for i,data in ipairs(playerData) do setElementData(source,data[1],getAccountData(account,data[1])) end end) addEventHandler("onPlayerQuit",root,function() local account = getPlayerAccount(source) if account then for i,data in ipairs(playerData) do setAccountData(account,data[1],getElementData(source,data[1])) end end end) And once again I went to the server, the value of a elementData is not available, it just is not saved. Debug shows that the value of an elementData has not been determined. So it has not been preserved. What to do? .
#DRAGON!FIRE Posted September 28, 2014 Posted September 28, 2014 Good day guys. I had a no problem, but rather a question. I've been working with Lua, but with a not yet encountered. Does not work saving a date element if its value is worth in braces "{}" That's actually made an example for you to understand: --"elementData" value is {2,0.1,0.3,0.8,0.9} -- -- --EXAMPLE: setElementData(source,"elementData",{2,0.1,0.3,0.8,0.9}) playerData = {{"elementData"}} addEventHandler("onPlayerLogin",root,function() account = getPlayerAccount(source) for i,data in ipairs(playerData) do setElementData(source,data[1],getAccountData(account,data[1])) end end) addEventHandler("onPlayerQuit",root,function() local account = getPlayerAccount(source) if account then for i,data in ipairs(playerData) do setAccountData(account,data[1],getElementData(source,data[1])) end end end) And once again I went to the server, the value of a elementData is not available, it just is not saved. Debug shows that the value of an elementData has not been determined. So it has not been preserved. What to do? . elementData just a value in table and u get value ( name ) and set data i mean like this : local nData = { { "saveData" } } -- nData [ 1 ] [ 1 ] = "saveData" setElementData ( root, nData [ 1 ] [ 1 ], true ) just u get name data and u use data with this name To Contact Me at Skype : [email protected]
Anubhav Posted September 28, 2014 Posted September 28, 2014 Element data's are stored in tables some thing like this. someData = {} setElementData( source, "someTest", "hi") -- now it will turn into someData = { [source's uservalue]={{data="someTest", value="hi"}}, } -- I am not sure, but I guess they use nested tables, Whenever you quit the user data changes ( i assume that ) and so you can't get it back from the table I suggest you use tables wherever possible. Do not use setElementData/getElementData until its 100% important because it takes alot of CPU and using it alot can cause lag. 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
iPanda Posted September 28, 2014 Author Posted September 28, 2014 elementData just a value in table and u get value ( name ) and set data i mean like this : local nData = { { "saveData" } } -- nData [ 1 ] [ 1 ] = "saveData" setElementData ( root, nData [ 1 ] [ 1 ], true ) just u get name data and u use data with this name You offered me some other option, but with Google translator translation I do not understand. I need my version and how I can save.
#DRAGON!FIRE Posted September 28, 2014 Posted September 28, 2014 u want save elementdata in table ? To Contact Me at Skype : [email protected]
Anubhav Posted September 28, 2014 Posted September 28, 2014 Just use SQL lol. What language do you talk in? We can't help you like this. 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
iPanda Posted September 28, 2014 Author Posted September 28, 2014 Problem solved! It was necessary to use: toJSON and fromJSON.
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