Maggi Posted December 21, 2010 Share Posted December 21, 2010 (edited) I have question about setElementData function - why I can't save tables in element? It is very useful to allocate some data with player (RGP table of stats) of vehicle (RPG vehicle data: fuel, numberplate, engine number, etc) so, my code was: players.lua ... function playerOnJoin () local pdata = {} pdata.Money = 1100 setElementData ( source, "rpgdata", pdata, false ) -- DO NOT SYNC end ... another module.lua ... function someFunction ( player ) local pdata = getElementData ( player, "rpgdata", false ) pdata.Money = pdata.Money + 1000 -- doesn't work outside this function end ... testing pdata == nil -> returns true, why? Edited December 21, 2010 by Guest Link to comment
Arran Posted December 21, 2010 Share Posted December 21, 2010 I have question about setElementData function - why I can't save tables in element? You can. Maybe it doesn't work cause you've got that third arg in getElementData, something I've never used. Link to comment
Maggi Posted December 21, 2010 Author Share Posted December 21, 2010 Syntax var getElementData ( element theElement, string key [, inherit = true] ) Required Arguments * theElement: This is the element with data you want to retrieve. * key: The name of the element data entry you want to retrieve. (Maximum 31 characters.) Optional Arguments * inherit: - toggles whether or not the function should go up the hierarchy to find the requested key in case the specified element doesn't have it. After brainfucking tests I found that I can retrieve tables from elements using getElementData...but, seems to be that this function copies result table instead of returning pointer (handle) to table...so all manipulations with table didn't being saved until I call setElementData... this means that setElementData copies whole table to element data ??? 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