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!

[All Versions] Allows something to show only when you login

Legendary Battlemage
Loyal Member
Joined
Sep 28, 2008
Messages
600
Reaction score
291
Basically, this is something like a function which allows you to display a message only when you login and it will not show when you change channel/coming out from cash shop. Besides message, you can even put others such as pop-up NPC, etc.

First:

MapleClient.java
PHP:
private boolean message;

public boolean messageOn() {
    PreparedStatement ps;
    try {
        ps = DatabaseConnection.getConnection().prepareStatement("SELECT message FROM accounts WHERE id = ?");
        ps.setInt(1, this.getAccID());
        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
            if (rs.getInt("message") == 0) {
                message = false;
            } else {
                message = true;
	    }
        }
        rs.close();
        ps.close();
    } catch (Exception e) {
        System.out.println("message error");
    }
    return message;
}
	
    public void setMessageToggle(int x) {
        try {
            PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("UPDATE accounts SET message = ? WHERE id = ?");
            ps.setInt(1, x);
            ps.setInt(2, getAccID());
            ps.executeUpdate();
            ps.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

LoginPasswordHandler
Add:
PHP:
c.setMessageToggle(0);
right after
PHP:
if (c.finishLogin(true) == 0) {

PlayerLoggedInHandler
PHP:
if (!c.messageOn()) {
	player.dropMessage("Welcome to RageZone! If you see this, means your server is useless."); // EDIT here for your usage
	c.setMessageToggle(1); 
}

SQL
PHP:
ALTER TABLE `accounts` ADD `message` tinyint(1) NOT NULL DEFAULT '0';

Credits to me. And yea, I'm sure there's a shorter way to do it.

-AuroX
 
Last edited:
may web.very maple.pls.
Loyal Member
Joined
Aug 12, 2009
Messages
1,810
Reaction score
606
Re: [Release] Allows something to show only when you login and not when changing chan

well, for the PlayerLoggedInHandler,doesn't it open when you open CS as well? Also does this only works once? since its toggle when you show msg.
 
Legendary Battlemage
Loyal Member
Joined
Sep 28, 2008
Messages
600
Reaction score
291
Re: [Release] Allows something to show only when you login and not when changing chan

Yes, this is used to show only once, means only when you login.
 
may web.very maple.pls.
Loyal Member
Joined
Aug 12, 2009
Messages
1,810
Reaction score
606
Re: [Release] Allows something to show only when you login and not when changing chan

Yes, this is used to show only once, means only when you login.
I see, thats what you meant by:
which allows you to display a message only when you login and it will not show when you change channel
Because you can't change channel while logging in, I get it..

PHP:
public boolean messageOn() { // Boolean so only a yes or no 
    PreparedStatement ps; // get information from mysql
    try {
        ps = DatabaseConnection.getConnection().prepareStatement("SELECT message FROM accounts WHERE id = ?"); // select column - message from accounts
        ps.setInt(1, this.getAccID()); // id = ? = id = "accID"
        ResultSet rs = ps.executeQuery(); // executes above 
        while (rs.next()) {
            if (rs.getInt("message") == 0) { // if message equal 0 returns false if else return true
                message = false;
            } else {
                message = true;
	    }
        }
        rs.close(); // close Result Set
        ps.close(); // close PreparedStatement
    } catch (Exception e) {
        System.out.println("message error"); // can't get info from mysql
    }
    return message; // get the results and returns it
}

PHP:
public void setMessageToggle(int x) {
        try {
            PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("UPDATE accounts SET message = ? WHERE id = ?"); // touch mysql 
            ps.setInt(1, x); // message = ? equal the value putted in the int x. ex 0 or 1
            ps.setInt(2, getAccID()); // id = ? equals accID
            ps.executeUpdate(); // executes
            ps.close();// close PreparedStatement
        } catch (SQLException e) {
            e.printStackTrace(); // error touching mysql tables
        }
    }
Did I get this right? I wanna learn since I never learned the right way on Java..
 
Legendary Battlemage
Loyal Member
Joined
Sep 28, 2008
Messages
600
Reaction score
291
Yes, you're right since PlayerLoggedInHandler handles everything when it spawns your player on the map, such as exit cash shop, log in, change channel but I don't get what u meant by "Because you can't change channel while logging in" o_O
 
Last edited:
may web.very maple.pls.
Loyal Member
Joined
Aug 12, 2009
Messages
1,810
Reaction score
606
Yes, you're right but I don't get what u meant by "Because you can't change channel while logging in" o_O
Like when you log in like press the login button in character selection it executes playerloggedinhandler at that moment and you can't change channels while your logging in o-o

edit: just forget about it ;x
 
Last edited:
Legendary Battlemage
Loyal Member
Joined
Sep 28, 2008
Messages
600
Reaction score
291
o_O Login -> specific channel. Once you're in a channel, then only u can change.
 
may web.very maple.pls.
Loyal Member
Joined
Aug 12, 2009
Messages
1,810
Reaction score
606
o_O Login -> specific channel. Once you're in a channel, then only u can change.
Once you are logging in the game after you enter your PIC you can't change channels till your character loads on the map and your in game
 
Legendary Battlemage
Joined
Mar 30, 2009
Messages
672
Reaction score
676
In short... this does if not exactly then close to what Notes do.
 
may web.very maple.pls.
Loyal Member
Joined
Aug 12, 2009
Messages
1,810
Reaction score
606
In short... this does if not exactly then close to what Notes do.
Not basically is a msg system only one message that gets toggle once its shown Notes just send notes from others many times and have a little notice on when a note came this one just dropmessage it o-o but its a bit similar to it
 
Legendary Battlemage
Joined
Mar 30, 2009
Messages
672
Reaction score
676
Not basically is a msg system only one message that gets toggle once its shown Notes just send notes from others many times and have a little notice on when a note came this one just dropmessage it o-o but its a bit similar to it

Ultimately they do nearly the same thing, If you really just rather drop a message other than add a line of code to Notes and have it display neatly then why not just edit Notes and have it do both (DropMessage and use the little message box). Reason why I'm suggesting it is so you won't need the 80%+ of the extra code.

But its just an idea, you could use this I guess.

Oh another suggestion, messageOn method would be better run along with login so you don't read the db twice.
 
Custom Title Activated
Loyal Member
Joined
Mar 17, 2009
Messages
1,911
Reaction score
538
Easy but nice (Y)
 
Experienced Elementalist
Joined
Aug 27, 2008
Messages
256
Reaction score
81
I've been looking for a method of doing this, thanks. But for some reason the message doesn't appear at all. Oh well, I'll figure it out.
 
Back
Top