Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[fixed]Get Level to Display in ui.java

Newbie Spellweaver
Joined
Sep 3, 2009
Messages
38
Reaction score
0
I have been trying for about 5 hours to get the Trainer level of your Player to display in the HUD because I am working on a new HUD to release. I tried about the same methods as the "getmoney" like how the money is updated when the game is loaded. The problem I am having is that the settext that loads is -1, which is the assigned var at the initial update. when i go and buy a pokeball or do anything to cause the update again. it will finally update to the correct trainer level. I used mainly UI.java and copied the get money methods. then changed them to the getTrainerLevel and changed the location display.

If anyone knows how to make the trainer level display correctly, that would be awesome! :D
BTW: i did try the same method as the Dialogbox with the stats of the character, also came out as -1, while the stat dialog came out as the correct character level.
 
Last edited:
Newbie Spellweaver
Joined
Sep 3, 2009
Messages
38
Reaction score
0
Re: Get Level to Display in ui.java

ill giveu a hint;

Trainer level:
T-Exp * 1.25 + 0.3333

No, Sorry, that Didn't work :(

Here is what I did.

In UI.java in the client.

below "this.add(m_moneyLabel);" I added.
Code:
		// Trainer data labels
		m_trainerLabel.setText("Wait");
		m_trainerLabel.pack();
		m_trainerLabel.setLocation(110, 6);
		m_trainerLabel.setVisible(true);
		m_trainerLabel.setFont(GameClient.getFontLarge());
		m_trainerLabel.setForeground(new Color(255, 255, 255));
		this.add(m_trainerLabel);
//

Then in the Method that starts with public void update(boolean money...etc

in the first IF statement I added. This below "m_moneyLabel.pack();"
Code:
    			m_trainerLabel.setText(""+(GameClient.getInstance().getOurPlayer().getTrainerLevel()));
				m_trainerLabel.pack();

:( it changes from "wait" to "-1" then when I goto buy a pokeball it updates to "25"<-My Level. I cant get it to loop it correctly to make it update until it is no longer -1. :)
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
Oh! nevermind, i figured it out. by adding 2 methods. I added.
this to the bottom on Ui.java.

Code:
/**
	 * Returns the level
	 * @return the level
	 */
	public int getlevel(){
		return lvl;
	}
	
	/**
	 * Sets the server version to be displayed
	 * @param lvl
	 */
	public void setCorrectTrainerlevel(int lvl) {
		m_trainerLabel.setText(" "+ lvl);
		m_trainerLabel.pack();
	}

then I went to do the TcpProtocolHandler.java and added in case 't':
Code:
					GameClient.getInstance().getUi().setCorrectTrainerlevel(Integer.parseInt(message.substring(3)));
before the break;

Then i went back to the Update method I mentioned earlier in Ui.java and went to double check that the first if is

Code:
    			m_moneyLabel.setText("$" + String.valueOf(GameClient.getInstance().getOurPlayer().getMoney()));	
    			m_moneyLabel.pack();
    			m_trainerLabel.setText(" "+GameClient.getInstance().getOurPlayer().getTrainerLevel());
    			m_trainerLabel.pack();


and there you have it!
 
Newbie Spellweaver
Joined
Sep 3, 2009
Messages
38
Reaction score
0
the hint wasn't helpful. I just figured it out by looking at server rev and following how the rev updated in the tcpprotocolhandler. But your reply motivated me to give it a second try.
 
Back
Top