Jump to content
  • 0

[Help] enterworld if statement


Meikis

Question

When I'm checking character username when character enters the world if statement don't work even if it should. For e.g.

if (activeChar.getName() == "Admin") { activeChar.sendMessage("Hello Admin");}

,this part of code is placed in enterworld.java, it is L2jserver H5. Btw when i just using

activeChar.sendMessage(activeChar.getName);

it works...

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

It's getName()

Plus it is a common mistake to compare strings using == operator. Don't do that! Here's an example:

String a = new String ("a");
String b = new String ("a");
System.out.println (a == b);

Will return false. "Why?" you ask? That's your homework for tonight ;)

Link to comment
Share on other sites

  • 0

When I'm checking character username when character enters the world if statement don't work even if it should. For e.g.

if (activeChar.getName == "Admin") { activeChar.sendMessage("Hello Admin")}

,this part of code is placed in enterworld.java, it is L2jserver H5. Btw when i just using

activeChar.sendMessage(activeChar.getName);

it works...

 

Character username? If you mean the account ID, That wouldn't work....

but if you just want to check the name, then this Would work, as mogo said. also you might need to put ; in the end, before the } symbol.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...