KariiiM Posted July 13, 2017 Share Posted July 13, 2017 (edited) Hey, As the title says, Is there another method to attach the player userdata under a key onLogin without using the elementdatas? Thanks, Edited July 13, 2017 by KariiiM 1 Link to comment
kieran Posted July 13, 2017 Share Posted July 13, 2017 I'd say setAccountData..... But that is the same, are you looking to use this on a login script? Link to comment
koragg Posted July 13, 2017 Share Posted July 13, 2017 (edited) You can always use SQLite or MySQL databases for any sort of stuff, but don't look at me for help with that I hate SQL, account and element data all the way. Edited July 13, 2017 by koragg Link to comment
Gordon_G Posted July 14, 2017 Share Posted July 14, 2017 I don't use element datas anymore because of the CPU usage and also for secure reasons. I use only one table and tree functions : datas_ = {} function setElementData_(element,data,value) if isElement(element) then if not datas_[element] then datas_[element] = {} end datas_[element][data] = value end end function getElementData_(element,data) if isElement(element) then if not datas_[element] or not datas_[element][data] then return false end return datas_[element][data] end end function dellAllElementData(element) datas_[element] = nil end Link to comment
Simple0x47 Posted July 14, 2017 Share Posted July 14, 2017 On 7/13/2017 at 06:49, KariiiM said: Hey, As the title says, Is there another method to attach the player userdata under a key onLogin without using the elementdatas? Thanks, An optimized way talking about speed would be this one. -- VARIABLES -- PLAYER local players = {} -- WHERE THE PLAYER IDS ARE BEING STORED FOR EACH PLAYER ELEMENT local players_ids = {} -- THE PLAYER DATA SAVED UNDER AN INTEGER KEY -- FUNCTION -- INIT PLAYER local function initPlayer( thePlayer ) if ( thePlayer ) then if not ( players[ thePlayer ] ) then local thePlayerID = #players_ids + 1 or 1 players[ thePlayer ] = thePlayerID players_ids[ thePlayerID ] = {} -- NOW WE CAN SAVE DATA FOR THIS PLAYER players_ids[ thePlayerID ][ "logged_in" ] = false players_ids[ thePlayerID ][ "xyz" ] = { 0, 0, 0 } -- IT'S RECOMMENDED TO STORE AS MUCH AS POSSIBLE INTO ONE KEY AVOIDING FRAGMENTATION else local thePlayerID = players[ thePlayer ] players_ids[ thePlayerID ] = nil players[ thePlayer ] = nil return initPlayer( thePlayer ) end end end 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