error making a point store

Diamond293Diamond293 Member, PRO Posts: 11

In my game i have a store where the user can buy different characters to use in the game. they use the points the gathered in the game to purchase these characters.

i have a save function that saves the points and its working fine
i have another save function thats a bool that declares whether the character has been bought and that works fine

but whenever i buy a character and then reload the game, the users points automatically sets itself to 1. no matter what is goes to 1.

Comments

  • pHghostpHghost London, UKMember Posts: 2,342

    How are you saving the points? If you are saving them, are you then loading them when the game starts after a reload?

  • Diamond293Diamond293 Member, PRO Posts: 11
    edited February 2017

    saving the points works perfectly! and when i reload the game the points loads perfectly
    its only after i purchase the new character that the points goes to 1.

    if i set the value of the store object to say 50 points and i have 100, when i buy it, it leaves me with 50 points and it displays 50 points

    but when i reload the game or leave the store and go back into the store it goes to 1

  • pHghostpHghost London, UKMember Posts: 2,342

    Are you doing a scene change? Could be anything, sounds like a rogue rule somewhere. Is 1 the default value, or is it 0?

    How about using tables to save it?

  • Diamond293Diamond293 Member, PRO Posts: 11

    i found the problem!

    in the code I had:

    when buy button is pressed

    change attribute money - 100

    save attribute money

    change attribute unlocked character to true

    save attribute unlocked character

    to fix my problem I just changed the order of code to :

    when buy button is pressed

    change attribute money - 100

    change attribute unlocked character to true

    save attribute unlocked character

    save attribute money

    just doing this simple swap fixed my bug!

    thanks for your time and help pHghost appreciate it!

Sign In or Register to comment.