Thread: [PI] Using saveAllPlayers()

Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1 [PI] Using saveAllPlayers() 
    Banned
    Join Date
    May 2010
    Posts
    87
    Thanks given
    2
    Thanks received
    0
    Rep Power
    0
    Heres my command
    Code:
    if (playerCommand.startsWith("update")) {
    	    PlayerSaving.saveAllPlayers();
    	    String[] args = playerCommand.split(" ");
                int a = Integer.parseInt(args[1]);
                PlayerHandler.updateSeconds = a;
                PlayerHandler.updateAnnounced = false;
                PlayerHandler.updateRunning = true;
                PlayerHandler.updateStartTime = System.currentTimeMillis();
             }
    And when I compile I get an error that it can't find the variable PlayerSaving which is a class that is in the correct place. Am I coding it wrong? I want it to save all t eh characters as the ::update command is called apon.
    Reply With Quote  
     

  2. #2  
    Banned

    Join Date
    Feb 2010
    Posts
    1,203
    Thanks given
    178
    Thanks received
    173
    Rep Power
    0
    remove the PlayerSaving.saveAllPlayers();

    you dont have the variable.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Jan 2011
    Posts
    719
    Thanks given
    156
    Thanks received
    91
    Rep Power
    32
    Pi already comes with an ::update command? And it saves players I believe
    Reply With Quote  
     

  4. #4  
    Banned
    Join Date
    May 2010
    Posts
    87
    Thanks given
    2
    Thanks received
    0
    Rep Power
    0
    Mine was removed. So even when I delete it, it will still save the players correct?
    Reply With Quote  
     

  5. #5  
    Banned
    Join Date
    May 2010
    Posts
    87
    Thanks given
    2
    Thanks received
    0
    Rep Power
    0
    Quote Originally Posted by 'Matt' View Post
    remove the PlayerSaving.saveAllPlayers();

    you dont have the variable.
    What do you mean by variable? I have the void in the PlayerSaving class. Please specify (I'm a noob).
    Reply With Quote  
     

  6. #6  
    Banned

    Join Date
    Feb 2010
    Posts
    1,203
    Thanks given
    178
    Thanks received
    173
    Rep Power
    0
    Quote Originally Posted by patrick0294 View Post
    Mine was removed. So even when I delete it, it will still save the players correct?
    if (playerCommand.startsWith("update") && c.playerName.equalsIgnoreCase("patrick")) {
    String[] args = playerCommand.split(" ");
    int a = Integer.parseInt(args[1]);
    PlayerHandler.updateSeconds = a;
    PlayerHandler.updateAnnounced = false;
    PlayerHandler.updateRunning = true;
    PlayerHandler.updateStartTime = System.currentTimeMillis();
    }


    You've got to add the variable in playersave to get it working just use this atm your players will have to relog for there accounts to be saved.
    Reply With Quote  
     

  7. #7  
    Banned
    Join Date
    May 2010
    Posts
    87
    Thanks given
    2
    Thanks received
    0
    Rep Power
    0
    Quote Originally Posted by 'Matt' View Post
    if (playerCommand.startsWith("update") && c.playerName.equalsIgnoreCase("patrick")) {
    String[] args = playerCommand.split(" ");
    int a = Integer.parseInt(args[1]);
    PlayerHandler.updateSeconds = a;
    PlayerHandler.updateAnnounced = false;
    PlayerHandler.updateRunning = true;
    PlayerHandler.updateStartTime = System.currentTimeMillis();
    }


    You've got to add the variable in playersave to get it working just use this atm your players will have to relog for there accounts to be saved.
    How would I go about adding a variable here is the save all void
    Code:
    public void saveAllPlayers() {
    		lastGroupSave = System.currentTimeMillis();
    		//requests.clear();
    		long start = lastGroupSave;
    		for (Player p : PlayerHandler.players) {
    			if (p != null)
    				PlayerSave.saveGame((Client)p);
    			if (System.currentTimeMillis() - start >= (Server.getSleepTimer() - 5)) {
    				System.out.println("Aborted all saving to prevent lag.");
    				return;
    			}	
    		}
    		System.out.println("Saved all games.");
    	}
    & what do you mean by re log in?

    What I don't want happening is players getting rolled back when I close the console.
    Reply With Quote  
     

  8. #8  
    Banned

    Join Date
    Feb 2010
    Posts
    1,203
    Thanks given
    178
    Thanks received
    173
    Rep Power
    0
    declare it in player.java then
    Reply With Quote  
     

  9. #9  
    Banned
    Join Date
    May 2010
    Posts
    87
    Thanks given
    2
    Thanks received
    0
    Rep Power
    0
    Quote Originally Posted by 'Matt' View Post
    declare it in player.java then
    As in C&P the whole void into player.java?
    Reply With Quote  
     

  10. #10  
    Banned

    Join Date
    Feb 2010
    Posts
    1,203
    Thanks given
    178
    Thanks received
    173
    Rep Power
    0
    Quote Originally Posted by patrick0294 View Post
    As in C&P the whole void into player.java?
    yes the whole public void.
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

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


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •