Thread: Chat filter help PL1X PL0X PL1X

Page 1 of 2 12 LastLast
Results 1 to 10 of 17
  1. #1 Chat filter help PL1X PL0X PL1X 
    slayer621
    Guest
    ~~~~PROBLEM SOLVED~~~~~~






    So I wanna add a chat filter, or rather edit my chat filter. Currently I am using a Mithscape 508 source. The part I'm dealing with in PublicChat.java says:

    Code:
    if (p.rights == 0) {
        if(p.chatText.startsWith("shit") || p.chatText.startsWith("fuck") || p.chatText.startsWith("whore") || p.chatText.startsWith("slut")) {
            p.chatText = "****";
            }
    }
    (I don't get any errors while compiling, that's not the problem.)

    Right now, when the text contains shit, fuck, etc., it replaces the whole line with "****". What I want to do is, replace only the swear word with ****, or another word. What I need help with is what to put instead of
    Code:
    p.chat = "****"

    Any help will be appreciated
    Reply With Quote  
     

  2. #2  
    zeroeh
    Guest
    Use a substring.
    Reply With Quote  
     

  3. #3  
    slayer621
    Guest
    Sorry, I should have elaborated more, my java coding skills is that of a kindergartner; maybe a 1st grader. In short, I don't even know what a substring is. Can you elaborate for a noob?
    Reply With Quote  
     

  4. #4  
    rockdawg1113
    Guest
    i am having the same problem! i am also new to java and would like to get to know it better (i have been php coding for a while now) and id like a tutorial on substrings.
    Reply With Quote  
     

  5. #5  
    Cortex_
    Guest
    p.chatText.replaceAll("shit", "****");
    p.chatText.replaceAll("fuck", "****");
    p.chatText.replaceAll("gay", "***");

    Get the picture?
    Reply With Quote  
     

  6. #6 Sorry 
    rockdawg1113
    Guest
    I am sorry. i am sort of a noob at coding java (as i said before), and i have been trial-and-erroring for a while trying to get this darn filter to work! here is my code

    Code:
    if(p.chatText.contains("shit") || p.chatText.contains("fuck") || p.chatText.contains("gay")) {
    	p.chatText.replaceAll("shit", "****");
    	p.chatText.replaceAll("fuck", "****");
    	p.chatText.replaceAll("gay", "***");
        }
    please tell me what i have wrong. sorry to bother you, but i'd like to get this accomplished by sunrise
    Reply With Quote  
     

  7. #7  
    slayer621
    Guest
    Help is appreciated, unfortunately, its still not working. I built it fine with no errors, but it doesn't replace anything with ****. What, specifically should I put? If what you posted is specifically what I should put, where do I put it?
    Reply With Quote  
     

  8. #8  
    Banned

    Join Date
    Jul 2008
    Age
    26
    Posts
    5,826
    Thanks given
    1,301
    Thanks received
    197
    Rep Power
    0
    Strings are immutable, you cannot change them. so,
    p.chatText = p.chatText.replaceAll("shit", "****");
    Reply With Quote  
     

  9. #9  
    Registered Member

    Join Date
    Sep 2008
    Posts
    1,801
    Thanks given
    4
    Thanks received
    50
    Rep Power
    636
    search the threads i posted i made a tutorial on this a couple of months ago
    Reply With Quote  
     

  10. #10  
    rockdawg1113
    Guest
    thanks java' it worked!! zach thanks for the help but my problem is solved
    Reply With Quote  
     

Page 1 of 2 12 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
  •