Mirage Source
http://www.miragesource.net/forums/

Client Swear Filter With Replaces
http://www.miragesource.net/forums/viewtopic.php?f=183&t=4431
Page 1 of 74

Author:  JokeofWeek [ Tue Sep 23, 2008 2:47 am ]
Post subject:  Client Swear Filter With Replaces

This is based on William's tutorial. I found it a little unoptimized. So I did a little modification to it, and I also added in a replacing system. . First, in mod Globals, go add the following :

Code:
Public SwearArray() as string
Public ReplaceSwearArray() as string
.

Now, go to sub Main. At the top, declare the following variable :

Code:
Public SwearString as string


In the same sub, right after :

Code:
Call CheckTiles


add :

Code:
' Use the swear string to store the original swear words
SwearString = "ass,fuck,shit,bitch,damn,cunt,whore,piss"
SwearArray = Split(SwearString, ",")

' Use the swear string to store the replace swear words
SwearString = "donkey,luck,matress,lucky charms,cow,moo,jokeofweek,yellow"
ReplaceSwearArray = Split(SwearString, ",")


Now, to add in your own words, just add the swear word to the first string, and then add the replacement to the second string :)

Now, just add this function (a modified version of CheckMessage) :

Code:
Public Function CheckMessage(byval Msg As String) As String
Dim i As Long

    CheckMessage = Msg

    For i = 0 To UBound(SwearArray)
           CheckMessage = Replace$(CheckMessage , SwearArray(i), ReplaceSwearArray(i), , , vbTextCompare)
    Next i
   
End Function


And there you go, you now have an optimized chat filter system which replaces swears with what you want them to. And, to quote william,:

Quote:
Now search for all the different messages: adminmsg, saymsg, broadcastmsg, globalmsg, playermsg, mapmsg.

And do this on all of them:
Code:
Call GlobalMsg(ChatText)

Replace it with:
Code:
Call GlobalMsg(CheckMessage(ChatText))

And of course you shouldn't replace the saymsg call with a globalmsg call...

Good Luck And have Fun

Author:  GIAKEN [ Tue Sep 23, 2008 2:56 am ]
Post subject:  Re: Client Swear Filter With Replaces

Unfortunately, it won't work...it will only replace the last swear word in the string. Like this:

Msg = "shit whore fuck bitch" for example...

CheckMessage = "**** whore fuck bitch" but Msg is still the same so it will look for the second swear...so then

CheckMessage = "shit ***** fuck bitch" and then Msg will still equal the same thing...so you do:

Code:
Public Function CheckMessage(byval Msg As String) As String
Dim i As Long
   
    For i = 0 To UBound(SwearArray)
        CheckMessage = Replace$(Msg, SwearArray(i), ReplaceSwearArray(i), , , vbTextCompare)
        If CheckMessage <> Msg Then Msg = CheckMessage
    Next i
   
End Function


Also changed i to a Long because it's the fastest type to use for loops.

Author:  JokeofWeek [ Tue Sep 23, 2008 2:58 am ]
Post subject:  Re: Client Swear Filter With Replaces

GIAKEN wrote:
Unfortunately, it won't work...it will only replace the last swear word in the string. Like this:

Msg = "shit whore fuck bitch" for example...

CheckMessage = "**** whore fuck bitch" but Msg is still the same so it will look for the second swear...so then

CheckMessage = "shit ***** fuck bitch" and then Msg will still equal the same thing...so you do:

Code:
Public Function CheckMessage(byval Msg As String) As String
Dim i As Long
   
    For i = 0 To UBound(SwearArray)
        CheckMessage = Replace$(Msg, SwearArray(i), ReplaceSwearArray(i), , , vbTextCompare)
        If CheckMessage <> Msg Then Msg = CheckMessage
    Next i
   
End Function


Also changed i to a Long because it's the fastest type to use for loops.


Ah true, thanks for that first fix, hadn't thought of that. And yeah, I thought of using I as a long for the loop, I'll probably do that :). Thanks for that mate :)

Author:  wanai [ Wed Dec 01, 2021 7:53 am ]
Post subject:  Re: Client Swear Filter With Replaces

http://audiobookkeeper.ruhttp://cottagenet.ruhttp://eyesvision.ruhttp://eyesvisions.comhttp://factoringfee.ruhttp://filmzones.ruhttp://gadwall.ruhttp://gaffertape.ruhttp://gageboard.ruhttp://gagrule.ruhttp://gallduct.ruhttp://galvanometric.ruhttp://gangforeman.ruhttp://gangwayplatform.ruhttp://garbagechute.ruhttp://gardeningleave.ruhttp://gascautery.ruhttp://gashbucket.ruhttp://gasreturn.ruhttp://gatedsweep.ruhttp://gaugemodel.ruhttp://gaussianfilter.ruhttp://gearpitchdiameter.ru
http://geartreating.ruhttp://generalizedanalysis.ruhttp://generalprovisions.ruhttp://geophysicalprobe.ruhttp://geriatricnurse.ruhttp://getintoaflap.ruhttp://getthebounce.ruhttp://habeascorpus.ruhttp://habituate.ruhttp://hackedbolt.ruhttp://hackworker.ruhttp://hadronicannihilation.ruhttp://haemagglutinin.ruhttp://hailsquall.ruhttp://hairysphere.ruhttp://halforderfringe.ruhttp://halfsiblings.ruhttp://hallofresidence.ruhttp://haltstate.ruhttp://handcoding.ruhttp://handportedhead.ruhttp://handradar.ruhttp://handsfreetelephone.ru
http://hangonpart.ruhttp://haphazardwinding.ruhttp://hardalloyteeth.ruhttp://hardasiron.ruhttp://hardenedconcrete.ruhttp://harmonicinteraction.ruhttp://hartlaubgoose.ruhttp://hatchholddown.ruhttp://haveafinetime.ruhttp://hazardousatmosphere.ruhttp://headregulator.ruhttp://heartofgold.ruhttp://heatageingresistance.ruhttp://heatinggas.ruhttp://heavydutymetalcutting.ruhttp://jacketedwall.ruhttp://japanesecedar.ruhttp://jibtypecrane.ruhttp://jobabandonment.ruhttp://jobstress.ruhttp://jogformation.ruhttp://jointcapsule.ruhttp://jointsealingmaterial.ru
http://journallubricator.ruhttp://juicecatcher.ruhttp://junctionofchannels.ruhttp://justiciablehomicide.ruhttp://juxtapositiontwin.ruhttp://kaposidisease.ruhttp://keepagoodoffing.ruhttp://keepsmthinhand.ruhttp://kentishglory.ruhttp://kerbweight.ruhttp://kerrrotation.ruhttp://keymanassurance.ruhttp://keyserum.ruhttp://kickplate.ruhttp://killthefattedcalf.ruhttp://kilowattsecond.ruhttp://kingweakfish.ruhttp://kinozones.ruhttp://kleinbottle.ruhttp://kneejoint.ruhttp://knifesethouse.ruhttp://knockonatom.ruhttp://knowledgestate.ru
http://kondoferromagnet.ruhttp://labeledgraph.ruhttp://laborracket.ruhttp://labourearnings.ruhttp://labourleasing.ruhttp://laburnumtree.ruhttp://lacingcourse.ruhttp://lacrimalpoint.ruhttp://lactogenicfactor.ruhttp://lacunarycoefficient.ruhttp://ladletreatediron.ruhttp://laggingload.ruhttp://laissezaller.ruhttp://lambdatransition.ruhttp://laminatedmaterial.ruhttp://lammasshoot.ruhttp://lamphouse.ruhttp://lancecorporal.ruhttp://lancingdie.ruhttp://landingdoor.ruhttp://landmarksensor.ruhttp://landreform.ruhttp://landuseratio.ru
http://languagelaboratory.ruhttp://largeheart.ruhttp://lasercalibration.ruhttp://laserlens.ruhttp://laserpulse.ruhttp://laterevent.ruhttp://latrinesergeant.ruhttp://layabout.ruhttp://leadcoating.ruhttp://leadingfirm.ruhttp://learningcurve.ruhttp://leaveword.ruhttp://machinesensible.ruhttp://magneticequator.ruhttp://magnetotelluricfield.ruhttp://mailinghouse.ruhttp://majorconcern.ruhttp://mammasdarling.ruhttp://managerialstaff.ruhttp://manipulatinghand.ruhttp://manualchoke.ruhttp://medinfobooks.ruhttp://mp3lists.ru
http://nameresolution.ruhttp://naphtheneseries.ruhttp://narrowmouthed.ruhttp://nationalcensus.ruhttp://naturalfunctor.ruhttp://navelseed.ruhttp://neatplaster.ruhttp://necroticcaries.ruhttp://negativefibration.ruhttp://neighbouringrights.ruhttp://objectmodule.ruhttp://observationballoon.ruhttp://obstructivepatent.ruhttp://oceanmining.ruhttp://octupolephonon.ruhttp://offlinesystem.ruhttp://offsetholder.ruhttp://olibanumresinoid.ruhttp://onesticket.ruhttp://packedspheres.ruhttp://pagingterminal.ruhttp://palatinebones.ruhttp://palmberry.ru
http://papercoating.ruhttp://paraconvexgroup.ruhttp://parasolmonoplane.ruhttp://parkingbrake.ruhttp://partfamily.ruhttp://partialmajorant.ruhttp://quadrupleworm.ruhttp://qualitybooster.ruhttp://quasimoney.ruhttp://quenchedspark.ruhttp://quodrecuperet.ruhttp://rabbetledge.ruhttp://radialchaser.ruhttp://radiationestimator.ruhttp://railwaybridge.ruhttp://randomcoloration.ruhttp://rapidgrowth.ruhttp://rattlesnakemaster.ruhttp://reachthroughregion.ruhttp://readingmagnifier.ruhttp://rearchain.ruhttp://recessioncone.ruhttp://recordedassignment.ru
http://rectifiersubstation.ruhttp://redemptionvalue.ruhttp://reducingflange.ruhttp://referenceantigen.ruhttp://regeneratedprotein.ruhttp://reinvestmentplan.ruhttp://safedrilling.ruhttp://sagprofile.ruhttp://salestypelease.ruhttp://samplinginterval.ruhttp://satellitehydrology.ruhttp://scarcecommodity.ruhttp://scrapermat.ruhttp://screwingunit.ruhttp://seawaterpump.ruhttp://secondaryblock.ruhttp://secularclergy.ruhttp://seismicefficiency.ruhttp://selectivediffuser.ruинфоhttp://semifinishmachining.ruhttp://spicetrade.ruhttp://spysale.ru
http://stungun.ruhttp://tacticaldiameter.ruhttp://tailstockcenter.ruhttp://tamecurve.ruhttp://tapecorrection.ruhttp://tappingchuck.rutaskreasoning.ruhttp://technicalgrade.ruhttp://telangiectaticlipoma.ruhttp://telescopicdamper.ruсайтhttp://temperedmeasure.ruhttp://tenementbuilding.rutuchkashttp://ultramaficrock.ruhttp://ultraviolettesting.ru

Author:  wanai [ Wed Dec 29, 2021 12:19 am ]
Post subject:  Re: Client Swear Filter With Replaces

Econ

Author:  wanai [ Wed Dec 29, 2021 12:20 am ]
Post subject:  Re: Client Swear Filter With Replaces

55.2

Author:  wanai [ Wed Dec 29, 2021 12:21 am ]
Post subject:  Re: Client Swear Filter With Replaces

Bett

Author:  wanai [ Wed Dec 29, 2021 12:22 am ]
Post subject:  Re: Client Swear Filter With Replaces

Bett

Author:  wanai [ Wed Dec 29, 2021 12:24 am ]
Post subject:  Re: Client Swear Filter With Replaces

Side

Author:  wanai [ Wed Dec 29, 2021 12:25 am ]
Post subject:  Re: Client Swear Filter With Replaces

Lieb

Author:  wanai [ Wed Dec 29, 2021 12:26 am ]
Post subject:  Re: Client Swear Filter With Replaces

Walk

Author:  wanai [ Wed Dec 29, 2021 12:27 am ]
Post subject:  Re: Client Swear Filter With Replaces

Jorg

Author:  wanai [ Wed Dec 29, 2021 12:28 am ]
Post subject:  Re: Client Swear Filter With Replaces

Juli

Author:  wanai [ Wed Dec 29, 2021 12:29 am ]
Post subject:  Re: Client Swear Filter With Replaces

Fair

Author:  wanai [ Wed Dec 29, 2021 12:30 am ]
Post subject:  Re: Client Swear Filter With Replaces

Bigb

Author:  wanai [ Wed Dec 29, 2021 12:32 am ]
Post subject:  Re: Client Swear Filter With Replaces

Prov

Author:  wanai [ Wed Dec 29, 2021 12:33 am ]
Post subject:  Re: Client Swear Filter With Replaces

Zero

Author:  wanai [ Wed Dec 29, 2021 12:34 am ]
Post subject:  Re: Client Swear Filter With Replaces

Weee

Author:  wanai [ Wed Dec 29, 2021 12:35 am ]
Post subject:  Re: Client Swear Filter With Replaces

Jame

Author:  wanai [ Wed Dec 29, 2021 12:36 am ]
Post subject:  Re: Client Swear Filter With Replaces

Xerx

Author:  wanai [ Wed Dec 29, 2021 12:37 am ]
Post subject:  Re: Client Swear Filter With Replaces

Dine

Author:  wanai [ Wed Dec 29, 2021 12:38 am ]
Post subject:  Re: Client Swear Filter With Replaces

Duns

Author:  wanai [ Wed Dec 29, 2021 12:39 am ]
Post subject:  Re: Client Swear Filter With Replaces

Full

Author:  wanai [ Wed Dec 29, 2021 12:41 am ]
Post subject:  Re: Client Swear Filter With Replaces

Kath

Author:  wanai [ Wed Dec 29, 2021 12:42 am ]
Post subject:  Re: Client Swear Filter With Replaces

Plus

Page 1 of 74 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/