Offline Mail System!

Page 1 of 2 12 LastLast
Results 1 to 15 of 28
  1. #1
    Interesting... SharpAceX is offline
    SubscriberRank
    Oct 2008 Join Date
    1,905Posts

    Offline Mail System!


    RaGEZONE Recommends

    RaGEZONE Recommends

    Hello good people of RaGEZONE. I coded this a while back for a server I used to code for. To be perfectly honest, it's pretty useless. I coded it to learn and experiment.

    Basically what this is, is it lets players send mail to each others, that works offline and online. Let's get started.

    Add these methods in MapleCharacter.java
    Code:
      public void setSeenAllMail() {
            try {
                PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("UPDATE mail SET `read` = 1 WHERE MailReciever = ?");
                ps.setString(1, getName());
                ps.executeUpdate();
                ps.close();
            } catch (SQLException e) {
                return;
            }
        }
    Code:
    public int newMail() {
            int mail = 0;
            PreparedStatement ps = null;
            Connection con = DatabaseConnection.getConnection();
            try {
                ps = con.prepareStatement("SELECT COUNT(*) as c FROM mail where mailreciever = ? and `read` = 0 and deleted = 0");
                ps.setString(1, getName());
                ResultSet rs = ps.executeQuery();
                if (rs.next()) {
                 mail = rs.getInt("c");
                }
                rs.close();
                ps.close();
            } catch (SQLException e) {
            } finally {
                try {
                    if (ps != null) {
                        ps.close();
                    }
                } catch (SQLException ex) {
                }
            }
            return mail;
        }
    Code:
    public void sendMail(String Reciever, String message) throws SQLException {
    		Connection con = DatabaseConnection.getConnection();
    		PreparedStatement ps = con.prepareStatement("INSERT INTO mail (`MailSender`, `MailReciever`, `Message`) VALUES (?, ?, ?)");
    		ps.setString(1, getName());
    		ps.setString(2, Reciever);
    		ps.setString(3, message);
    		ps.executeUpdate();
    		ps.close();
    	}
    Open up your player commands file and add these commands.
    Code:
    } else if (splitted[0].equals("@checkallmail")) {
                           c.getPlayer().setSeenAllMail();
                 ResultSet rs = getAllMail(c.getPlayer().getName());
                               try { 
                                   mc.dropMessage("Your MailBox:");
                                   while(rs.next()){
    
                                      mc.dropMessage(rs.getString("MailSender") + ": " + rs.getString("Message"));
                                   }
                                } catch(Exception ex) {}
    Code:
    } else if (splitted[0].equals("@checknewmail")) {
                       if (c.getPlayer().newMail() > 0) {
                         
                 ResultSet rs = getNewMail(c.getPlayer().getName());
                               try {
                                   mc.dropMessage("Your New Messages:");
                                   while(rs.next()){
    
                                      mc.dropMessage(rs.getString("MailSender") + ": " + rs.getString("Message"));
                                   }
                                } catch(Exception ex) {}
     c.getPlayer().setSeenAllMail();
               } else {
                      mc.dropMessage("You have no new messages. Use @checkallmail to see your entire inbox.");
               }
    Code:
    } else if (splitted[0].equalsIgnoreCase("@sendmail")) {
                        if (!player.getCheatTracker().Spam(60000, 2)) {
                        if (splitted.length <= 2) {
    mc.dropMessage("Please use @sendmail <Mail Reciever> <Message>.");
    } else {
         MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
         String Reciever = splitted[1];
         String message = StringUtil.joinStringFrom(splitted, 2);
         c.getPlayer().sendMail(Reciever, message);
         mc.dropMessage("You have sent " + Reciever + " this message: " + message);
         victim.dropMessage("[Notice]: " + c.getPlayer().getName() + " has just sent you a message! Use @checknewmail to see what it was.");
    }
                        } else {
                        mc.dropMessage("You cannot send a message more than once per minute.");
                    }
    Add these at the bottom of your player commands file:
    Code:
    public static ResultSet getAllMail(String Reciever) {
    		try {
    			Connection con = DatabaseConnection.getConnection();
    		PreparedStatement ps = con.prepareStatement("SELECT MailSender, Message FROM mail WHERE MailReciever = ? and Deleted = 0");
                    ps.setString(1, Reciever);
                     return ps.executeQuery();
    
    		} catch (Exception ex) {}
    
    		return null;
    	}
    Code:
    public static ResultSet getNewMail(String Reciever) {
    		try {
    			Connection con = DatabaseConnection.getConnection();
    		PreparedStatement ps = con.prepareStatement("SELECT MailSender, Message FROM mail WHERE MailReciever = ? and Deleted = 0 and `Read` = 0");
                    ps.setString(1, Reciever);
                     return ps.executeQuery();
    
    		} catch (Exception ex) {}
    
    		return null;
    	}
    Open up your PlayerLoggedinHandler.java and add this near the bottom:
    Code:
                    if (c.getPlayer().newMail() > 0) {
                        player.dropMessage("[Notice]: You have " + c.getPlayer().newMail() + " unread messages.");
                    }
    Run this MySQL: (Edit TABLENAMEHERE to your server's table name.)
    Code:
    CREATE TABLE `TABLENAMEHERE`.`Mail` (
      `MessageID` INT(10) NOT NULL AUTO_INCREMENT,
      `MailSender` VARCHAR(13) NOT NULL,
      `MailReciever` VARCHAR(13) NOT NULL,
      `Message` VARCHAR(128) NOT NULL,
      `Read` TINYINT(4) NOT NULL DEFAULT 0,
      `Deleted` TINYINT(4) UNSIGNED NOT NULL DEFAULT 0,
      PRIMARY KEY (`MessageID`)
    )
    ENGINE = InnoDB;
    And you're done! This works but I'm not sure if I got all the pieces together.

    Here's a screen of it in action:


    Have fun!


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

    Re: Offline Mail System!

    I think this was released before,
    maybe a different method. Good job
    tho. Thanks~

  3. #3
    Account Inactive tsunayoshi is offline
    InactiveRank
    Aug 2009 Join Date
    100Posts

    Re: Offline Mail System!

    nice release , btw bloodangel13 what's ur msn ?

  4. #4
    Interesting... SharpAceX is offline
    SubscriberRank
    Oct 2008 Join Date
    1,905Posts

    Re: Offline Mail System!

    Quote Originally Posted by tsunayoshi View Post
    nice release , btw bloodangel13 what's ur msn ?
    SharpMS@live.com

    Quote Originally Posted by Xoslize View Post
    I think this was released before,
    maybe a different method. Good job
    tho. Thanks~
    Really? I haven't seen this before.

    Well mines allows for deleting messages, checking only new messages, checking all messages and a notification when you log in or receive a message.

  5. #5
    none seryi is offline
    True MemberRank
    Apr 2005 Join Date
    Honk KongLocation
    833Posts

    Re: Offline Mail System!

    DestinyMS had something(or) like this back in v62.. player mail and guild mail, if i'm not wrong.
    ███▄▄▄▄▄ ▃▃▃▃▃▃▄~~~
    ▄▅██████▅▄▃▂
    ████████████████
    ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

  6. #6
    Account Inactive ItsKevin is offline
    InactiveRank
    Aug 2009 Join Date
    Austin, TexasLocation
    171Posts

    Re: Offline Mail System!

    Quote Originally Posted by seryi View Post
    DestinyMS had something(or) like this back in v62.. player mail and guild mail, if i'm not wrong.
    SydneyMS too

  7. #7
    none seryi is offline
    True MemberRank
    Apr 2005 Join Date
    Honk KongLocation
    833Posts

    Re: Offline Mail System!

    Quote Originally Posted by ItsKevin View Post
    SydneyMS too
    I never see a SydneyMS release in ragezone, I talk about Destiny released sources.
    ███▄▄▄▄▄ ▃▃▃▃▃▃▄~~~
    ▄▅██████▅▄▃▂
    ████████████████
    ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤

  8. #8
    Interesting... SharpAceX is offline
    SubscriberRank
    Oct 2008 Join Date
    1,905Posts

    Re: Offline Mail System!

    Wish I'd known this earlier. Oh well, I doubt theirs was exactly the same as this.

  9. #9
    Account Inactive ItsKevin is offline
    InactiveRank
    Aug 2009 Join Date
    Austin, TexasLocation
    171Posts

    Re: Offline Mail System!

    Sydney's was somewhat like this. You logged in it tells you if your inbox, new messages blah blah blah, you read and you reply

  10. #10
    Interesting... SharpAceX is offline
    SubscriberRank
    Oct 2008 Join Date
    1,905Posts

    Re: Offline Mail System!

    Well that sucks. I never played Sydney or Destiny so I wouldn't know. At least I can say I made my own working version. D:

  11. #11
    Ooo, shiny! FateJiki is offline
    True MemberRank
    Feb 2008 Join Date
    1,064Posts

    Re: Offline Mail System!

    This was released under a different method (By using notes, but in v75 it doesn't work..).

    Great release though!

  12. #12
    Interesting... SharpAceX is offline
    SubscriberRank
    Oct 2008 Join Date
    1,905Posts

    Re: Offline Mail System!

    Quote Originally Posted by FateJiki View Post
    This was released under a different method (By using notes, but in v75 it doesn't work..).

    Great release though!
    Yeah I haven't gotten Notes to work in v75 either.

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

    Re: Offline Mail System!

    that never worked in v75 for me xD
    Ontopic looks nice great release ;)

  14. #14
    Gamma Samus. is offline
    GammaRank
    Jun 2008 Join Date
    wvndesign.nlLocation
    3,332Posts

    Re: Offline Mail System!

    Very nicely done.
    In need of a website or design? Click here to send me a PM.




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

    Re: Offline Mail System!

    Added to Library, Great work on this :D




Page 1 of 2 12 LastLast

Advertisement