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

Results 1 to 15 of 15
  1. #1
    Account Upgraded | Title Enabled! AuroX is offline
    True MemberRank
    Sep 2008 Join Date
    1,435Posts

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


    RaGEZONE Recommends

    RaGEZONE Recommends

    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 Code:
    private boolean message;

    public 
    boolean messageOn() {
        
    PreparedStatement ps;
        try {
            
    ps DatabaseConnection.getConnection().prepareStatement("SELECT message FROM accounts WHERE id = ?");
            
    ps.setInt(1this.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(1x);
                
    ps.setInt(2getAccID());
                
    ps.executeUpdate();
                
    ps.close();
            } catch (
    SQLException e) {
                
    e.printStackTrace();
            }
        } 
    LoginPasswordHandler
    Add:
    PHP Code:
    c.setMessageToggle(0); 
    right after
    PHP Code:
    if (c.finishLogin(true) == 0) { 
    PlayerLoggedInHandler
    PHP Code:
    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 Code:
    ALTER TABLE `accountsADD `messagetinyint(1NOT NULL DEFAULT '0'
    Credits to me. And yea, I'm sure there's a shorter way to do it.

    -AuroX
    Last edited by AuroX; 01-12-10 at 07:53 PM.


  2. #2
    may web.very maple.pls. iAkira is offline
    Alpha MaleRank
    Aug 2009 Join Date
    somewhere..Location
    2,383Posts

    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.

  3. #3
    Account Upgraded | Title Enabled! AuroX is offline
    True MemberRank
    Sep 2008 Join Date
    1,435Posts

    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.

  4. #4
    may web.very maple.pls. iAkira is offline
    Alpha MaleRank
    Aug 2009 Join Date
    somewhere..Location
    2,383Posts

    Re: [Release] Allows something to show only when you login and not when changing chan

    Quote Originally Posted by yenpooh View Post
    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 Code:
    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(1this.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 Code:
    public void setMessageToggle(int x) {
            try {
                
    PreparedStatement ps DatabaseConnection.getConnection().prepareStatement("UPDATE accounts SET message = ? WHERE id = ?"); // touch mysql 
                
    ps.setInt(1x); // message = ? equal the value putted in the int x. ex 0 or 1
                
    ps.setInt(2getAccID()); // 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..

  5. #5
    Account Upgraded | Title Enabled! AuroX is offline
    True MemberRank
    Sep 2008 Join Date
    1,435Posts

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

    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 by AuroX; 01-12-10 at 07:46 PM.

  6. #6
    may web.very maple.pls. iAkira is offline
    Alpha MaleRank
    Aug 2009 Join Date
    somewhere..Location
    2,383Posts

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

    Quote Originally Posted by yenpooh View Post
    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 by iAkira; 01-12-10 at 07:48 PM.

  7. #7
    Account Upgraded | Title Enabled! AuroX is offline
    True MemberRank
    Sep 2008 Join Date
    1,435Posts

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

    O.o Login -> specific channel. Once you're in a channel, then only u can change.

  8. #8
    may web.very maple.pls. iAkira is offline
    Alpha MaleRank
    Aug 2009 Join Date
    somewhere..Location
    2,383Posts

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

    Quote Originally Posted by yenpooh View Post
    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

  9. #9
    Account Upgraded | Title Enabled! XiuzSu is offline
    Mar 2009 Join Date
    c.getXiuzSu.posLocation
    826Posts

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

    In short... this does if not exactly then close to what Notes do.

  10. #10
    may web.very maple.pls. iAkira is offline
    Alpha MaleRank
    Aug 2009 Join Date
    somewhere..Location
    2,383Posts

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

    Quote Originally Posted by XiuzSu View Post
    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

  11. #11
    Account Upgraded | Title Enabled! XiuzSu is offline
    Mar 2009 Join Date
    c.getXiuzSu.posLocation
    826Posts

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

    Quote Originally Posted by iAkira View Post
    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.

  12. #12
    Gamma Sparrow is offline
    GammaRank
    Mar 2009 Join Date
    SydneyLocation
    2,968Posts

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

    Easy but nice (Y)

  13. #13
    Account Upgraded | Title Enabled! redeemer34 is offline
    True MemberRank
    Aug 2008 Join Date
    335Posts

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

    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.

  14. #14
    while(true) spam(); kevintjuh93 is offline
    ModeratorRank
    Jun 2008 Join Date
    The NetherlandsLocation
    4,118Posts

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

    sendNotes much?
    Quote Originally Posted by mavin0107 View Post
    can anyone tell me how to make pokemon system in lithium work cuz i try to go to a map have pokemon but there are no pokemon in that map
    Quote Originally Posted by MentaL View Post
    ps... if you dont like butterflys then ur a homo.

  15. #15
    I'm overrated. Fraysa is offline
    GammaRank
    Apr 2008 Join Date
    4,763Posts

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

    Instead of this you can make a field in ServerConstants, and then set it on/off in ServerConstants.java. Then playerloggedinahndler, dropMessage.




Advertisement