GhostXoP Posted December 10, 2012 Share Posted December 10, 2012 When retrieving a string from a key using getAccountData is just the string retrieved? HelloWorld and not HelloWorldDATAUSEDFORMTA Does it return the exact data, like when placed there in the first place? Link to comment
Tete omar Posted December 10, 2012 Share Posted December 10, 2012 (edited) Why are you asking all these silly questions? , of course it'll return a string contains the data you've added to just that nothing else of what you expect, and next time read the wiki. Edited December 10, 2012 by Guest Link to comment
GhostXoP Posted December 10, 2012 Author Share Posted December 10, 2012 (edited) Edit: Good boy, No Cussing. Edited December 10, 2012 by Guest Link to comment
Cadu12 Posted December 10, 2012 Share Posted December 10, 2012 Did you made your own new function? Link to comment
GhostXoP Posted December 10, 2012 Author Share Posted December 10, 2012 I've decided on rewriting a version of MTA's set/getAccountData procedure to take Arrays, for now i have this. Would you like the source? Link to comment
Cadu12 Posted December 10, 2012 Share Posted December 10, 2012 Do you mean you are making new function for array(toJSON)? Link to comment
GhostXoP Posted December 10, 2012 Author Share Posted December 10, 2012 (edited) -- Edited December 10, 2012 by Guest Link to comment
Cadu12 Posted December 10, 2012 Share Posted December 10, 2012 (edited) local _getAccountData = getAccountData local _setAccountData = setAccountData function getAccountData(account, key, json) if (not json) then json = false end if (json) then local count = _getAccountData(account, key) local jsonstring = "" if (tonumber(count)) then for i = 1, count do local jsonsub = _getAccountData(account, key + i) jsonstring = jsonstring + jsonsub end end return fromJSON(jsonstring) else return _getAccountData(account, key) end end Try test it, I can't test myself. Edited December 10, 2012 by Guest Link to comment
GhostXoP Posted December 10, 2012 Author Share Posted December 10, 2012 (edited) -- No. I already wrote my version, if i didn't, i wouldn't be here. The data DOES SAVE, I get -- EXAMPLE HelloWorld, I am not Human <- as it should be HelloWorld rld, I am not Human. this is just an example of how it comes out, over lapped. My bottom code retrieving the blocks, do as they should and retrieve in order but, it comes out over lapped. (Which means Look at Retrieval code) In a nut shell, --, turn the string into an array, then return it. Its returning it over lapped. This is not the fault of my save code, because i have showing (in the image) proof that it saved correctly, with the correct key number order. Edited December 10, 2012 by Guest Link to comment
Castillo Posted December 10, 2012 Share Posted December 10, 2012 Maybe you should consider using SQLite instead of account data. Link to comment
GhostXoP Posted December 10, 2012 Author Share Posted December 10, 2012 (edited) I had printed the data out to debug and it is all intact! it looks exactly as it should before JSONing it, but when i do, it says the sub array Weapons does not contain a --, it says its nil. Is there a chance fromJSON isnt completely creating the array? Edited December 10, 2012 by Guest Link to comment
Cadu12 Posted December 10, 2012 Share Posted December 10, 2012 local _getAccountData = getAccountData local _setAccountData = setAccountData function getAccountData(account, key) local checkifhasjson = false local number = _getAccountData(account, key) if (tonumber(number)) then local json = _getAccountData(account, key .. "0") if (#json ~= 0 and json ~= "") then checkifhasjson = true end end if (checkifhasjson) then local count = _getAccountData(account, key) local jsonstring = "" if (tonumber(count)) then for i = 0, count do local jsonsub = _getAccountData(account, key .. i) jsonstring = jsonstring .. jsonsub end end return fromJSON(jsonstring) else return _getAccountData(account, key) end end function setAccountData(account, key, value) local jsonstring = toJSON(value) if (tostring(key) and tostring(value)) then if (#jsonstring >= 128) then local count = 0 while (true) do _setAccountData(account, key .. count, string.sub(jsonstring, count * 64 + 1, (count + 1) * 64)) if (not (#string.sub(jsonstring, count * 64 + 1, (count + 1) * 64) >= 64)) then break end count = count + 1 end _setAccountData(account, key, count) else _setAccountData(account, key, value) end end end You should use my new function that allowed json without limits. Link to comment
GhostXoP Posted December 10, 2012 Author Share Posted December 10, 2012 (edited) Yours basically stores in blocks, using json right? Because its exactly what mine does, and mine does everything correctly, stand by and ill have pictures -- See, it works. I fromJSON the string, and send it to the client, the client gets the array and then it says the variables ammo and id within the array [22] within Weapons does not exist. Why is this? Its right there in the string, in good format, isn't it? Edited December 10, 2012 by Guest Link to comment
Tete omar Posted December 10, 2012 Share Posted December 10, 2012 Edit: Good boy, No Cussing. What do you really think , all your posts is barely stupid questions.. next time read the wiki It's simple to read It says password is optional, but required. It says if its not specified i can still get the account whatever the password is. otherwise the password must match the account. I have tried to use warpPedIntoVehicle(source, VEHICLE) and this does not seem to be working How can i spawn the player into a vehicle otherwise?(This is server side within an event handler triggered by the player) edit: if you think i'm a little kid like you , then you better back it off 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