erisP Posted May 19, 2022 Share Posted May 19, 2022 local tableData = getElementData(source,"dataT") or {} outputChatBox(toJSON(tableData)) print - [ { "38": 2, "30": 3 } ] addEventHandler("onPlayerQuit", root, function() local account = getPlayerAccount ( source ) local data = toJSON(getElementData(source,"dataT")) or {} setAccountData(account,"SaveP", data) end) addEventHandler("onPlayerLogin", root, function(_, account) local Paintjobs = fromJSON(getAccountData(account,"SaveP")) or toJSON({}) setElementData(source,"dataT",Paintjobs) end) hi, i can't save this where am i doing wrong? Link to comment
Syntrax# Posted May 19, 2022 Share Posted May 19, 2022 (edited) 9 minutes ago, erisP said: local tableData = getElementData(source,"dataT") or {} outputChatBox(toJSON(tableData)) print - [ { "38": 2, "30": 3 } ] addEventHandler("onPlayerQuit", root, function() local account = getPlayerAccount ( source ) local data = toJSON(getElementData(source,"dataT")) or {} setAccountData(account,"SaveP", data) end) addEventHandler("onPlayerLogin", root, function(_, account) local Paintjobs = fromJSON(getAccountData(account,"SaveP")) or toJSON({}) setElementData(source,"dataT",Paintjobs) end) hi, i can't save this where am i doing wrong? Does it throw any errors in Debugscript? Edited May 19, 2022 by Syntrax# Link to comment
erisP Posted May 19, 2022 Author Share Posted May 19, 2022 13 minutes ago, Syntrax# said: Does it throw any errors in Debugscript? i tested again and got no errors Link to comment
Flashmyname Posted May 19, 2022 Share Posted May 19, 2022 Hi! - i give you some hint to finish your code, this is an example. - in my version, you need to start this save protocol by an code, on clientside. -- CLIENTSIDE triggerServerEvent("loadCharacter", localPlayer, localPlayer) - -- SERVERSIDE function loadCharacter(player) triggerEvent("server:receiveStats", root, player) end addEvent("loadCharacter", true) addEventHandler("loadCharacter", root, loadCharacter) function saveAllPlayer() for _, player in ipairs(getElementsByType("player")) do saveOnePlayer(player) end end addEventHandler("onPlayerQuit", saveAllPlayer) setTimer(saveAllPlayer, 1000*60*30, 0) function saveAllPlayerCmd(p) for _, player in ipairs(getElementsByType("player")) do saveOnePlayer(player) end end addCommandHandler("saveall", saveAllPlayerCmd, false, false) 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