Use a substring.
|
|
~~~~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:
(I don't get any errors while compiling, that's not the problem.)Code:if (p.rights == 0) { if(p.chatText.startsWith("shit") || p.chatText.startsWith("fuck") || p.chatText.startsWith("whore") || p.chatText.startsWith("slut")) { p.chatText = "****"; } }
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 ofCode:p.chat = "****"
Any help will be appreciated![]()
![]()
![]()
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?
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.
p.chatText.replaceAll("shit", "****");
p.chatText.replaceAll("fuck", "****");
p.chatText.replaceAll("gay", "***");
Get the picture?
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
please tell me what i have wrong. sorry to bother you, but i'd like to get this accomplished by sunriseCode: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", "***"); }![]()
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?

Strings are immutable, you cannot change them. so,
p.chatText = p.chatText.replaceAll("shit", "****");

search the threads i posted i made a tutorial on this a couple of months ago
thanks java' it worked!! zach thanks for the help but my problem is solved
| « random thing | help with connecting to secter (525) » |
| Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |