Thread: "/" in Public chat isn't working?

Results 1 to 10 of 10
  1. #1 "/" in Public chat isn't working? 
    Ex Rune-Scaper

    Join Date
    Jun 2008
    Posts
    3,541
    Thanks given
    457
    Thanks received
    1,259
    Rep Power
    1003
    /*
    * Class PublicChat
    *
    * Version 1.0
    *
    * Sunday, August 17, 2008
    *
    * Created by Codeusa palis was crap i re did it
    */

    package net.com.net.packethandler;

    import net.com.Server;
    import net.com.model.Player;
    import net.com.util.Misc;
    import net.com.Engine;
    import net.com.content.clanchat.*;

    public class PublicChat implements Packet {
    /**
    * Handles player chatting.
    * @param p The Player which the frame should be handled for.
    * @param packetId The packet id this belongs to.
    * @param packetSize The amount of bytes being recieved for this packet.
    */
    public void handlePacket(Player p, int packetId, int packetSize) {
    if (p == null || p.stream == null) {
    return;
    }
    p.chatTextEffects = p.stream.readUnsignedWord();
    int numChars = p.stream.readUnsignedByte();
    p.chatText = Misc.decryptPlayerChat(p.stream, numChars);
    String chatText = Misc.decryptPlayerChat(p.stream, numChars);
    Engine.fileManager.appendData("characters/logs/ChatLogs/" + p.username + ".txt", "[" + Misc.getDate() + "] " + p.username +": "+ p.chatText);
    Engine.fileManager.appendData("characters/logs/ChatLogs/MasterChatLog.txt", "[" + Misc.getDate() + "] " + p.username +": " + p.chatText);
    for (String s : Engine.Censor.censored) {
    if (p.chatText.contains(s)) {
    int length = s.length();
    String replace = "";
    for(int i = 0; i < length; i++) {
    replace += "*";
    }
    p.chatText = p.chatText.replaceAll(s, replace);
    }
    }

    if (p.muteType > 0) {
    p.getActionSender().sendMessage(p, "You are muted and cannot talk.");
    return;
    }
    if (chatText.startsWith("/")) {
    if (p.clanRoom.length() > 0) {
    Engine.clanChat.sendMessage(p, chatText.substring(1));
    }

    String[] funny = {"lol", "l0l", "LOL", "lmao", "lmfao", "rofl", "lawl"}; // More here...

    for (String f : funny) {
    if (p.chatText.toLowerCase().contains(f)) {
    p.requestAnim(861, 1);
    }
    }

    String[] confused = {"what?", "who?", "when?", "where?", "huh?", "what the hell?", "what are you talking about?", "wtf?"}; // More here...

    for (String c : confused) {
    if (p.chatText.toLowerCase().contains(c)) {
    p.requestAnim(857, 1);
    }
    }

    String[] happy = {"yay", "woot", "w00t", "hooray"}; // More here...

    for (String h : happy) {
    if (p.chatText.toLowerCase().contains) {
    p.requestAnim(2109, 1);
    }
    }

    if (p.chatText.equalsIgnoreCase(p.lastMsg)) {
    return;
    }
    }
    p.chatTextUpdateReq = true;
    p.lastMsg = p.chatText;
    p.updateReq = true;
    }
    }
    Any IdeaS?

    What it does is when I type in "/" it just shows the text above the characters head instead of using it in ClanChat.

    Everything else works fine besides that.

    if (chatText.startsWith("/")) {
    if (p.clanRoom.length() > 0) {
    Engine.clanChat.sendMessage(p, chatText.substring(1));
    }
    Thats the code that uses that method... Must be in wrong place?
    Reply With Quote  
     

  2. #2  
    Hi.

    'Mystic Flow's Avatar
    Join Date
    Nov 2007
    Posts
    7,141
    Thanks given
    256
    Thanks received
    1,247
    Rep Power
    3636
    Created by Codeusa palis was crap i re did it
    This is more crappier then pali's lol, and you should make your text print out cause your server might possibly be crossing something out

    [Only registered and activated users can see links. ]

    Reply With Quote  
     

  3. #3  
    Ex Rune-Scaper

    Join Date
    Jun 2008
    Posts
    3,541
    Thanks given
    457
    Thanks received
    1,259
    Rep Power
    1003
    Well yeah its crappy its basic for now I'll redo the class later.
    Reply With Quote  
     

  4. #4  
    Banned

    Join Date
    Feb 2009
    Posts
    1,533
    Thanks given
    4
    Thanks received
    34
    Rep Power
    0
    Learn the java conventions...
    Reply With Quote  
     

  5. #5  
    Ex Rune-Scaper

    Join Date
    Jun 2008
    Posts
    3,541
    Thanks given
    457
    Thanks received
    1,259
    Rep Power
    1003
    Quote Originally Posted by popbob View Post
    Learn the java conventions...
    Learn that this is a "help" section and its not a spam my Fing thread section, therefore stop getting your post count up by spamming.

    I fixed the problem. Now im going to redo the class.
    Reply With Quote  
     

  6. #6  
    Hi.

    'Mystic Flow's Avatar
    Join Date
    Nov 2007
    Posts
    7,141
    Thanks given
    256
    Thanks received
    1,247
    Rep Power
    3636
    You have a bracket in the wrong place

    [Only registered and activated users can see links. ]

    Reply With Quote  
     

  7. #7  
    Ex Rune-Scaper

    Join Date
    Jun 2008
    Posts
    3,541
    Thanks given
    457
    Thanks received
    1,259
    Rep Power
    1003
    Quote Originally Posted by 'Mystic Flow View Post
    You have a bracket in the wrong place
    Yeah I noticed...
    Reply With Quote  
     

  8. #8  
    Registered Member
    Join Date
    Sep 2009
    Posts
    57
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    Replace it with this, and add whatever you had from before to it.
    than it should work.

    Code:
    /*
     * Class PublicChat
     *
     * Version 1.0
     *
     * Sunday, August 17, 2008
     *
     * Created by Codeusa palis was crap i re did it
     */
    
    package net.com.codeusa.net.packethandler;
    
    import net.com.codeusa.Server;
    import net.com.codeusa.model.Player;
    import net.com.codeusa.util.Misc;
    
    public class PublicChat implements Packet {
        /**
         * Handles player chatting.
         * @param p The Player which the frame should be handled for.
         * @param packetId The packet id this belongs to.
         * @param packetSize The amount of bytes being recieved for this packet.
         */
        public void handlePacket(Player p, int packetId, int packetSize) {
            if (p == null || p.stream == null) {
                return;
            }
            p.chatTextEffects = p.stream.readUnsignedWord();
            int numChars = p.stream.readUnsignedByte();
            p.chatText = Misc.decryptPlayerChat(p.stream, numChars);
    	if (p.muteType > 0) {
    		p.getActionSender().sendMessage(p, "You are muted and cannot talk.");
    		return;
    	}
    	if (p.chatText.startsWith("/")) {
    		try {
    			String chat = p.activeChat;
    			for (Player player : Server.engine.players) {
    				if (player != null) {
    					if (player.activeChatOwner.equals(p.activeChatOwner)) {
    						if (p.rights == 0 && p.donator == 0) {
    							p.getActionSender().sendMessage(p, "You must be a donator or apart of the staff to use yell.");
    						} else if (p.rights == 1) {
    							player.getActionSender().sendMessage(player, "[<col=0000ff>"+chat+"</col>] <img=0>"+p.username.substring(0, 1).toUpperCase()+p.username.substring(1)+": <col=880000>"+p.chatText.substring(1) +":clan:");
    						} else if (p.rights >= 2) {
    							player.getActionSender().sendMessage(player, "[<col=0000ff>"+chat+"</col>] <img=1>"+p.username.substring(0, 1).toUpperCase()+p.username.substring(1)+": <col=880000>"+p.chatText.substring(1) +":clan:");
    						} else if (p.donator == 1) {
    							player.getActionSender().sendMessage(player, "[<col=0000ff>"+chat+"</col>] <img=2>"+p.username.substring(0, 1).toUpperCase()+p.username.substring(1)+": <col=880000>"+p.chatText.substring(1) +":clan:");
    						}
    					}
    				}
    			}
    		} catch (Exception e) {
    			return;
    		}
    		return;
    	}
            p.chatTextUpdateReq = true;
            p.updateReq = true;
        }
    }
    Reply With Quote  
     

  9. #9  
    Ex Rune-Scaper

    Join Date
    Jun 2008
    Posts
    3,541
    Thanks given
    457
    Thanks received
    1,259
    Rep Power
    1003
    Quote Originally Posted by r a n g e d View Post
    Replace it with this, and add whatever you had from before to it.
    than it should work.

    Code:
    /*
     * Class PublicChat
     *
     * Version 1.0
     *
     * Sunday, August 17, 2008
     *
     * Created by Codeusa palis was crap i re did it
     */
    
    package net.com.codeusa.net.packethandler;
    
    import net.com.codeusa.Server;
    import net.com.codeusa.model.Player;
    import net.com.codeusa.util.Misc;
    
    public class PublicChat implements Packet {
        /**
         * Handles player chatting.
         * @param p The Player which the frame should be handled for.
         * @param packetId The packet id this belongs to.
         * @param packetSize The amount of bytes being recieved for this packet.
         */
        public void handlePacket(Player p, int packetId, int packetSize) {
            if (p == null || p.stream == null) {
                return;
            }
            p.chatTextEffects = p.stream.readUnsignedWord();
            int numChars = p.stream.readUnsignedByte();
            p.chatText = Misc.decryptPlayerChat(p.stream, numChars);
    	if (p.muteType > 0) {
    		p.getActionSender().sendMessage(p, "You are muted and cannot talk.");
    		return;
    	}
    	if (p.chatText.startsWith("/")) {
    		try {
    			String chat = p.activeChat;
    			for (Player player : Server.engine.players) {
    				if (player != null) {
    					if (player.activeChatOwner.equals(p.activeChatOwner)) {
    						if (p.rights == 0 && p.donator == 0) {
    							p.getActionSender().sendMessage(p, "You must be a donator or apart of the staff to use yell.");
    						} else if (p.rights == 1) {
    							player.getActionSender().sendMessage(player, "[<col=0000ff>"+chat+"</col>] <img=0>"+p.username.substring(0, 1).toUpperCase()+p.username.substring(1)+": <col=880000>"+p.chatText.substring(1) +":clan:");
    						} else if (p.rights >= 2) {
    							player.getActionSender().sendMessage(player, "[<col=0000ff>"+chat+"</col>] <img=1>"+p.username.substring(0, 1).toUpperCase()+p.username.substring(1)+": <col=880000>"+p.chatText.substring(1) +":clan:");
    						} else if (p.donator == 1) {
    							player.getActionSender().sendMessage(player, "[<col=0000ff>"+chat+"</col>] <img=2>"+p.username.substring(0, 1).toUpperCase()+p.username.substring(1)+": <col=880000>"+p.chatText.substring(1) +":clan:");
    						}
    					}
    				}
    			}
    		} catch (Exception e) {
    			return;
    		}
    		return;
    	}
            p.chatTextUpdateReq = true;
            p.updateReq = true;
        }
    }
    lol that would screw up all my code.
    Reply With Quote  
     

  10. #10  
    Registered Member
    Join Date
    Sep 2009
    Posts
    57
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    Quote Originally Posted by Sunny++ View Post
    lol that would screw up all my code.
    I tried. =P
    Reply With Quote  
     


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
  •