Jump to content

Account Data Save Problem


GhostXoP

Recommended Posts

Up until i had added a weapon into the array, it appears this isn't being saved, in fact, it isnt keeping the user logged in like it has before.

Before, i would set account data, but first get the account and it would appear as "logged in", but now, when i log out after account creation it says that the account wasn't logged in to begin with. I have a feeling i'm not getting the account / storing account data properly.

function CreateClientAccount(Username, Password) 
  
    if addAccount(Username,Password) == false then 
     
        triggerClientEvent(source,"AccountCreationProgress", getRootElement(), false) 
         
        return 
  
    else 
  
  
        --Set Player Stats 
        local PlayerBriefCase = { Weapons = {}, Health = {}, Vehicles = {}, Buildings = {}, HealthStat = 100, MoneyStat = 25 } 
  
        PlayerBriefCase.Weapons[22] = {ID = 22, Ammo = 5 } 
  
        local account = getAccount(Username, Password) 
  
        setAccountData(account, "Life.BriefCase", toJSON(PlayerBriefCase)) 
  
        outputChatBox(account) --Number outputs, the player is usually considered logged in at this point, but for some reason it stopped doing this.. 
  
        logOut(source) 
  
        triggerClientEvent(source,"AccountCreationProgress", getRootElement(), true) 
         
        return 
    end 
  
end 
  
  
  
  
addEvent("AccountCreationAttempt", true) 
addEventHandler("AccountCreationAttempt", getRootElement(), CreateClientAccount) 

Is the function that deals with creation of default stats, then gives the user a pistol (My way) for when that user logs in again

Link to comment

So i have figured out that the problem is when it gets to line 15. If i remove that, the data is saved, if i keep it the data is not. How is this happening, why is it not working?

Edit: *Its when i add anything to the table after its been declared it doesn't get saved.

Link to comment

None, the array is sent if its just line 13. If i involve 14, it does not send. I know this because it will set the money to 25 without 14, but with 14 i get errors saying the array is nil (array wasnt sent)

Ive tried sending as JSON strings, and regular arrays. Ive even sent and then used for and in pairs to merge all data. Its not getting stored

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...