Thread: [PI] Variable resetting after logout! help!

Results 1 to 4 of 4
  1. #1 [PI] Variable resetting after logout! help! 
    Registered Member
    Join Date
    Jun 2012
    Posts
    96
    Thanks given
    22
    Thanks received
    3
    Rep Power
    11
    Problem:I am doing a quest where it resets your killcount to zero, and sets kcReset = 1 (so I can track if it was reset or not, because after it is reset, the user is supposed to get x amount of kills to get a reward.

    I set it equal to one in clicking buttons and that works and everything, and in playerSave.java I have it working where it reads it and such:

    PlayerSave:
    Code:
    else if (token.equals("kcReset")) {
    						p.kcReset = Integer.parseInt(token2);
    					}
    and
    Code:
    characterfile.write("kcRest = ", 0, 9);
    			characterfile.write(Integer.toString(p.kcReset), 0, Integer.toString(p.kcReset).length());
    			characterfile.newLine();
    And in Player.java


    Code:
    	public int kcReset;
    So when it is set to 1 in game, it saves, but then I log back in and it is 1 again, then log out and it is 0!

    Help if you can
    Reply With Quote  
     

  2. #2  
    Donator

    DCTHost's Avatar
    Join Date
    May 2016
    Posts
    51
    Thanks given
    21
    Thanks received
    14
    Rep Power
    110
    In playersave you've named it
    Code:
    characterfile.write("kcRest = ", 0, 9);
    It needs to be kcReset. A simple spelling mistake I'm sure
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Registered Member
    Join Date
    Jun 2012
    Posts
    96
    Thanks given
    22
    Thanks received
    3
    Rep Power
    11
    Quote Originally Posted by Athenis View Post
    In playersave you've named it
    Code:
    characterfile.write("kcRest = ", 0, 9);
    It needs to be kcReset. A simple spelling mistake I'm sure
    That was it! hahahh silly me, man. Thanks so much!
    Reply With Quote  
     

  5. #4  
    Registered Member
    Stanaveli's Avatar
    Join Date
    Aug 2014
    Posts
    1,490
    Thanks given
    184
    Thanks received
    653
    Rep Power
    1338
    Quote Originally Posted by arch337 View Post
    As mention before this "characterfile.write("kcRest = ", 0, 9);" need to be "characterfile.write("kcReset= ", 0, 10);"
    or
    "else if (token.equals("kcReset")) {" into "else if (token.equals("kcRest")) {"
    last 2 params are not required when using the #write function. They are used to read the start and end index of the String and serve no purpose in the given context so you might aswel remove them.
    Keep your head up.



    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Reset on logout. Help!
    By Skyfall in forum Help
    Replies: 1
    Last Post: 01-06-2013, 04:05 PM
  2. Replies: 6
    Last Post: 09-29-2012, 03:21 AM
  3. [PI] Teleblock reset on logout
    By Tiggy in forum Help
    Replies: 1
    Last Post: 04-07-2012, 04:54 AM
  4. [pi] ips after logout?
    By Exile rsps in forum Help
    Replies: 1
    Last Post: 10-27-2011, 07:28 PM
  5. Replies: 5
    Last Post: 07-31-2010, 04:21 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •