Thread: [508][email protected]!~Basic Private [email protected]![508]

Page 1 of 3 123 LastLast
Results 1 to 10 of 25
  1. #1 [508][email protected]!~Basic Private [email protected]![508] 
    Registered Member
    mikelmao's Avatar
    Join Date
    Oct 2008
    Age
    26
    Posts
    690
    Thanks given
    18
    Thanks received
    64
    Rep Power
    166
    Please Post even if you hate it!!


    Description: This add's a very basic form of private chat tot your server. You can now chat with others..

    Difficulty: 2/10

    Assumed Knowledge: Know how to C&P.

    Tested Server: Massimo server (Should work on all).

    Files/Classes Modified: Commands.java, FileManger.java, Player.java

    Procedure
    Step 1: Open up Commands.java and search for:
    Code:
    } else if (cmd[0].equals("female")) {
                        p.look[0] = 48; // Hair
                        p.look[1] = 1000; // Beard
                        p.look[2] = 57; // Torso
                        p.look[3] = 64; // Arms
                        p.look[4] = 68; // Bracelets
                        p.look[5] = 77; // Legs
                        p.look[6] = 80; // Shoes
                        p.gender = 1;
                        p.appearanceUpdateReq = true;
                        p.updateReq = true;
    }
    Under that add this:
    Code:
    if (cmd[0].equals("pcuser")) {//By Mikelmao
    String pe = playerCommand.substring((playerCommand.indexOf(" ") + 1));
    Player p2 = Engine.players[Engine.getIdFromName(pe)];
    if (p2 != null && p2 != p) {
    p.frames.sendMessage(p, "You have set " + p2.username + " For your private chat");
    p.pchat =  p2.playerId;
    }
    else if(p2 == null) {
    p.frames.sendMessage(p, "This user is not online.");
    } else {
    p.frames.sendMessage(p, "You cant chat with yourself..");
    }
    }
    if (cmd[0].equals("pc") && p.muted == 0) {//By Mikelmao
    Player p2 = Engine.players[p.pchat];
    String pctext = playerCommand.substring(3);
    if(p.pchat == 0) {
    p.frames.sendMessage(p,"Please type ::pcuser [The user you want to message] then type ::pc [message]");
    }
    else if(p2 == null) {
    p.frames.sendMessage(p, "This user is not online");
    } else {
    if (p.rights == 0) {
    p2.frames.sendMessage(p2, "From: " + Misc.optimizeText(p.username) + ": <col=006600>" + Misc.optimizeText(pctext));
    p2.frames.sendMessage(p, "to: " + Misc.optimizeText(p2.username) + ": <col=006600>" + Misc.optimizeText(pctext));
    }
    else if (p.rights == 1) {
    p2.frames.sendMessage(p2, "From <img=0>" + Misc.optimizeText(p.username) + ": <col=006600>" + Misc.optimizeText(pctext));
    p2.frames.sendMessage(p, "to <img=0>" + Misc.optimizeText(p2.username) + ": <col=006600>" + Misc.optimizeText(pctext));
    }
    else if (p.rights == 2) {
    p2.frames.sendMessage(p2, "From <img=1>" + Misc.optimizeText(p.username) + ": <col=006600>" + Misc.optimizeText(pctext));
    p2.frames.sendMessage(p, "to <img=1>" + Misc.optimizeText(p2.username) + ": <col=006600>" + Misc.optimizeText(pctext));
    }
    Done with Client.java


    Step 2: Now, You open up FileManager.java and search for:
    Code:
    stream.writeString("gender:" + p.gender);
    Under that add
    Code:
    stream.writeString("Private Chat:" + p.pchat);
    now search for:
    Code:
    } else if (line.startsWith("gender:")) {
                        p.gender = Integer.parseInt(line.substring(7));
    and under it add:
    Code:
    } else if (line.startsWith("pchat:")) {
                        p.pchat = Integer.parseInt(line.substring(6));
    done with FileManger.java


    Step 3: Now open player.java and search for:
    Code:
    public int homeTele = 0;
    if you dont hav it, Search where all the public ints are.
    but add this where all the ints are(Under public int homeTele = 0
    Code:
    public int pchat = 0;
    And your done!


    How it works:
    This actually is ver easy. all you do is:
    Type :: pcuser [Username you wanrt to chat with]
    then type :: pc [Message]
    And it then he will be able to see it.

    Credits: This is 100% MADE BY ME,
    Reply With Quote  
     

  2. #2  
    Registered Member
    wizzyt21's Avatar
    Join Date
    Aug 2007
    Posts
    1,167
    Thanks given
    49
    Thanks received
    12
    Rep Power
    156
    Good job, but use:
    Code:
    line.toLowerCase().startsWith("pcchat:")
    Anyways, basic, but good job, keep it up, let's hope it's not leeched =), if it ain't good work and keep it up.
    YOU JUST GOT KNOCKED THE F*CK UP.
    Reply With Quote  
     

  3. #3  
    Registered Member
    mikelmao's Avatar
    Join Date
    Oct 2008
    Age
    26
    Posts
    690
    Thanks given
    18
    Thanks received
    64
    Rep Power
    166
    Believe me its not.. I worked about 4 hours on it =) (Im still new to coding)
    And leeching is noob so....
    Reply With Quote  
     

  4. #4  
    BowDeath4
    Guest
    Nvm fixed it thx for this =D
    Last edited by BowDeath4; 11-13-2008 at 09:23 AM. Reason: fixed my own problem
    Reply With Quote  
     

  5. #5  
    The internet's reject
    Andy's Avatar
    Join Date
    Jun 2007
    Age
    31
    Posts
    4,376
    Thanks given
    148
    Thanks received
    1,522
    Rep Power
    3133
    What the hell is wrong with you, you don't need all the // after every line.

    Fixed up code

    Code:
    } else if (cmd[0].equals("pcuser")) {
            String pe = playerCommand.substring((playerCommand.indexOf(" ") + 1));
            Player p2 = Engine.players[Engine.getIdFromName(pe)];
            if (p2 != null && p2 != p) {
                p.frames.sendMessage(p, "You have set " + p2.username + " For your private chat");
                p.pchat =  p2.playerId;
            }
            else if(p2 == null)
            {
                p.frames.sendMessage(p, "This user is not online.");
            }
            else
            {
                p.frames.sendMessage(p, "You cant chat with yourself..");
            }
        }
        else if (cmd[0].equals("pc") && p.muted == 0) {
            Player p2 = Engine.players[p.pchat];
            String pctext = playerCommand.substring(3);
            if(p.pchat == 0)
            {
                p.frames.sendMessage(p,"Please type ::pcuser [The user you want to message] then type ::pc [message]");
            }
            else if(p2 == null)
            {
                p.frames.sendMessage(p, "This user is not online");
            }
            else
            {
                if (p.rights == 0) {
                    p2.frames.sendMessage(p2, "From: " + Misc.optimizeText(p.username) + ": <col=006600>" + Misc.optimizeText(pctext));
                    p2.frames.sendMessage(p, "to: " + Misc.optimizeText(p2.username) + ": <col=006600>" + Misc.optimizeText(pctext));
                } else if (p.rights == 1) {
                    p2.frames.sendMessage(p2, "From <img=0>" + Misc.optimizeText(p.username) + ": <col=006600>" + Misc.optimizeText(pctext));
                    p2.frames.sendMessage(p, "to <img=0>" + Misc.optimizeText(p2.username) + ": <col=006600>" + Misc.optimizeText(pctext));
                } else if (p.rights == 2) {
                    p2.frames.sendMessage(p2, "From <img=1>" + Misc.optimizeText(p.username) + ": <col=006600>" + Misc.optimizeText(pctext));
                    p2.frames.sendMessage(p, "to <img=1>" + Misc.optimizeText(p2.username) + ": <col=006600>" + Misc.optimizeText(pctext));
                }
            }
    What am I watching now?

    Reply With Quote  
     

  6. #6  
    BowDeath4
    Guest
    Lol he put those there so ppl would no he did it =P
    thx for fixed up one tho
    lol i was a little confused because of all the words =D
    Reply With Quote  
     

  7. #7  
    The internet's reject
    Andy's Avatar
    Join Date
    Jun 2007
    Age
    31
    Posts
    4,376
    Thanks given
    148
    Thanks received
    1,522
    Rep Power
    3133
    And its indented so i saved you a few kb.
    What am I watching now?

    Reply With Quote  
     

  8. #8  
    Registered Member
    mikelmao's Avatar
    Join Date
    Oct 2008
    Age
    26
    Posts
    690
    Thanks given
    18
    Thanks received
    64
    Rep Power
    166
    Quote Originally Posted by Andrew View Post
    What the hell is wrong with you, you don't need all the // after every line.

    Fixed up code

    Code:
    } else if (cmd[0].equals("pcuser")) {//By Mikelmao
            String pe = playerCommand.substring((playerCommand.indexOf(" ") + 1));
            Player p2 = Engine.players[Engine.getIdFromName(pe)];
            if (p2 != null && p2 != p) {
                p.frames.sendMessage(p, "You have set " + p2.username + " For your private chat");
                p.pchat =  p2.playerId;
            }
            else if(p2 == null)
            {
                p.frames.sendMessage(p, "This user is not online.");
            }
            else
            {
                p.frames.sendMessage(p, "You cant chat with yourself..");
            }
        }
        else if (cmd[0].equals("pc") && p.muted == 0) {//By Mikelmao
            Player p2 = Engine.players[p.pchat];
            String pctext = playerCommand.substring(3);
            if(p.pchat == 0)
            {
                p.frames.sendMessage(p,"Please type ::pcuser [The user you want to message] then type ::pc [message]");
            }
            else if(p2 == null)
            {
                p.frames.sendMessage(p, "This user is not online");
            }
            else
            {
                if (p.rights == 0) {
                    p2.frames.sendMessage(p2, "From: " + Misc.optimizeText(p.username) + ": <col=006600>" + Misc.optimizeText(pctext));
                    p2.frames.sendMessage(p, "to: " + Misc.optimizeText(p2.username) + ": <col=006600>" + Misc.optimizeText(pctext));
                } else if (p.rights == 1) {
                    p2.frames.sendMessage(p2, "From <img=0>" + Misc.optimizeText(p.username) + ": <col=006600>" + Misc.optimizeText(pctext));
                    p2.frames.sendMessage(p, "to <img=0>" + Misc.optimizeText(p2.username) + ": <col=006600>" + Misc.optimizeText(pctext));
                } else if (p.rights == 2) {
                    p2.frames.sendMessage(p2, "From <img=1>" + Misc.optimizeText(p.username) + ": <col=006600>" + Misc.optimizeText(pctext));
                    p2.frames.sendMessage(p, "to <img=1>" + Misc.optimizeText(p2.username) + ": <col=006600>" + Misc.optimizeText(pctext));
                }
            }
    I fixed up the code, But please add the one //By Mikelmao ont every command as above.
    Reply With Quote  
     

  9. #9  
    Ben
    Guest
    This is more then most people did. Good Effort
    Reply With Quote  
     

  10. #10  
    matthewcarter
    Guest
    Kinda' nice, but I'm working on proper private chat so shant use, frames ftw?
    Reply With Quote  
     

Page 1 of 3 123 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •