In response to Narutogx2
How interesting, i didn't pick up that you've been starting each word with a capital letter until just now.. lol.
Is there any particular reason for that btw?
Its How I Type, lol.
No point in trying to filter profanity
Well Im Mostly Trying To Filter Out Racist Stuff, lol.
proc/replacetext(haystack, needle, replace)
var
pos = findtext(haystack, needle)
needleLen = length(needle)
replaceLen = length(replace)
while(pos)
haystack = copytext(haystack, 1, pos) + replace + \
copytext(haystack, pos+needleLen)
pos = findtext(haystack, needle, pos+replaceLen)
return haystack


// ...

message = replacetext(message, "i hate byond", "i suck")
lol. That Looks Like Something Already In The Code I Have.
proc/Filter(msg as text)
for(var/profane in profane) // Loop through the curse list

if(findtext(msg, profane)) // This is done in this example in case there's any words entered above that does not have another word replacing it
var/rep = profane[profane] // Get the replacement word if defined in the list above (ex: Ass is replaced with butt)

if(!rep) // If there is no replacement defined
for(var/i = 1 to length(profane)) // Or use that replicate function Pirion showed *shrug*
rep += "*" // Replace with * (or you can do pick(with,different,symbols) like how Theodis had his

msg = replace(msg, profane, rep)

return msg
The Question Is How Do I Define The Replace Function In The Second To Last Line.
Oh, didn't you already have a filter system implemented?
Eitherway, I'm sure someone already mentioned it earlier, but the replace function isn't a standard function. It was referenced as a function from within Forum_Account's small library of string functions (Here); you'd need to download and include that library first to use the replace function.

Alternatively, since Doohl posted his version of the code relevant to your needs, you could just make use of the snippet he's provided, and apply it by either changing the proc name from replacetext to replace, or changing the 2nd-to-last line to msg = replacetext(...).

The first option is probably the way to go, as typing less is preferable in the long run.
lol I Have A Filter System But Its Shitty.
Ok So I Defined Replace But Its Just Not Even Showing Up In OOC When I Test It, lol.
Ah... well are you perhaps forgetting the return at the end of your filter function like in present in the post that GhostAnime made?

mob/proc/profane(msg as text)
for(var/profane in profane) // Loop through the curse list
if(findtext(msg, profane)) // This is done in this example in case there's any words entered above that does not have another word replacing it
var/rep = profane[profane] // Get the replacement word if defined in the list above (ex: Ass is replaced with butt)

if(!rep) // If there is no replacement defined
for(var/i = 1 to length(profane)) // Or use that replicate function Pirion showed *shrug*
rep += "*" // Replace with * (or you can do pick(with,different,symbols) like how Theodis had his

msg = replace(msg, profane, rep)

return msg

mob/proc/bannedwords(msg as text)
for(var/bannedwords in bannedwords) // Loop through the curse list
if(findtext(msg, bannedwords)) // This is done in this example in case there's any words entered above that does not have another word replacing it
var/rep = bannedwords[bannedwords] // Get the replacement word if defined in the list above (ex: Ass is replaced with butt)

if(!rep) // If there is no replacement defined
for(var/i = 1 to length(bannedwords)) // Or use that replicate function Pirion showed *shrug*
rep += "*" // Replace with * (or you can do pick(with,different,symbols) like how Theodis had his

msg = replace(msg, bannedwords, rep)

return msg


Moderator note: Please surround your code with <DM> tags.
Should [bannedwords] Be *?
Btw I Don't Know How To Do DM Tags So Srry If I Didn't Put Them, lol.
Nor Do I Know What They Are
Page: 1 2