Forum

> > CS2D > Scripts > LUA Censoring Bad words
Forums overviewCS2D overview Scripts overviewLog in to reply

English LUA Censoring Bad words

3 replies
To the start Previous 1 Next To the start

old LUA Censoring Bad words

Baloon
GAME BANNED Off Offline

Quote
Hi, I just want to ask, may my code works? If you think I am spam, this code is different from other topics.

I have an example which disallows saying fuck
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
if badword == nil then badword = {} end
function badword.censorword(id,txt,word)
 t=string.lower(txt)
 w=string.lower(word)
 first = string.sub(w,1,1)
 mid = string.sub(w,2,(string.len(w)-1))
 last = string.sub(string.reverse(w),1,1)
 midlen = string.len(mid)
 string.gsub(w,"@","a") string.gsub(w,"5","s")
 string.gsub(w,"!","i") string.gsub(w,"6","b")
 string.gsub(w,"1","i") string.gsub(w,"7","t")
 string.gsub(w,"2","r") string.gsub(w,"8","b")
 string.gsub(w,"3","e") string.gsub(w,"9","q")
 string.gsub(w,"4","a") string.gsub(w,"0","o")
 string.gsub(w,"$","s")
 if string.find(t,word)~=nil then
  m = string.gsub(mid,mid,string.rep("*",midlen)
  txt2 = string.gsub(t,w,(first..""..m..""..last)
  msg(player(id,"name")..": "..txt2)
 end
end

addhook("say","badword.say")
function badword.say(id,tx)
 badword.censorword(id,txt,"fuck")
end

old Re: LUA Censoring Bad words

DC
Admin Off Offline

Quote
I recommend to just wait until you're able to test the script yourself. Creating a thread whenever you're unable to test your scripts is pretty inefficient and you actually don't have much benefit from it. Just testing and fixing yourself without posting is probably less time consuming.

This is just a recommendation though. Feel free to continue if you think it's a good idea

old Re: LUA Censoring Bad words

GeoB99
Moderator Off Offline

Quote
The script will both fail at syntax level (17 and 18 line) and the way you've assigned the variables to hold their value therefor it will not work as expected. I suggest you to read user TrialAndError's reply cause the samples are there for a reason.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview