Forum

> > CS2D > Scripts > Lua Problem
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Problem

6 replies
To the start Previous 1 Next To the start

old Lua Problem

itsoxymoron
User Off Offline

Quote
I'm making an "anti bad word" Lua for my server but a have an error
•anyone can help me?
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
27
28
function initArray(m)
local array = {}
for i = 1, m do
array[i]=0
end
return array
end
sample.badwords.words=initArray(32)
sample.badwords.words = {"boludo","cabron","cagar","chucha","cojido","cojones","comemierda","concha","conchudo","coño","culeado","culero","gilipollas","hijo de puta","orto","pajero","Pelotudo","pija","pinga","verga","zorra"}
addhook("say","sample.badwords.say")
function sample.badwords.say(p,t)
t=string.lower(t)
for i = 1,#sample.badwords.words do
if (string.find(t,sample.badwords.words[i])~=nil) then
sample.classes.flame[p]=sample.classes.flame[p]+1
msg("©255000000"..player(p,"name").." Has sido avisado. Avisos: "..sample.classes.flame[p].."/3")
topw = ("©255000000Aviso: "..sample.classes.flame[p].."/3")
xz = 10
yz = 250
tidz = 7
parse('hudtxt2 '..p..' '..tidz..' "'..topw..'" '..xz.." "..yz)
if sample.classes.flame[p]>= 3 then
parse("kick "..p)
sample.classes.flame[p]=sample.classes.flame[p]-3
end
end
end
end

old Re: Lua Problem

EngiN33R
Moderator Off Offline

Quote
You could as well tell us what the error is. From the first glance I don't see any problems.

old Re: Lua Problem

Banaan
User Off Offline

Quote
Change
1
sample.badwords.words=initArray(32)
to
1
sample.badwords.flame=initArray(32)

old Re: Lua Problem

EngiN33R
Moderator Off Offline

Quote
@Sparty
He says the script gives him an error, but doesn't say which one. Not good.

old Re: Lua Problem

itsoxymoron
User Off Offline

Quote
user Banaan has written
Change
1
sample.badwords.words=initArray(32)
to
1
sample.badwords.flame=initArray(32)


thx,but i have an error here

1
sample.classes.flame[p]=sample.classes.flame[p]+1
[LUA ERROR: sys/lua/server.lua:108: attempt to index field 'classes' (a nil value)
What should i do?

old Re: Lua Problem

Alistaire
User Off Offline

Quote
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
27
28
function initArray(m)
local array = {}
for i = 1, m do
array[i]=0
end
return array
end
sample.badwords.words=initArray(32)
sample.badwords.words = {"boludo","cabron","cagar","chucha","cojido","cojones","comemierda","concha","conchudo","coño","culeado","culero","gilipollas","hijo de puta","orto","pajero","Pelotudo","pija","pinga","verga","zorra"}
addhook("say","sample.badwords.say")
function sample.badwords.say(p,t)
t=string.lower(t)
for i = 1,#sample.badwords.words do
if (string.find(t,sample.badwords.words[i])~=nil) then
sample.badwords.flame[p]=sample.badwords.flame[p]+1
msg("©255000000"..player(p,"name").." Has sido avisado. Avisos: "..sample.badwords.flame[p].."/3")
topw = ("©255000000Aviso: "..sample.badwords.flame[p].."/3")
xz = 10
yz = 250
tidz = 7
parse('hudtxt2 '..p..' '..tidz..' "'..topw..'" '..xz.." "..yz)
if sample.badwords.flame[p]>= 3 then
parse("kick "..p)
sample.badwords.flame[p]=sample.badwords.flame[p]-3
end
end
end
end

That should work.
Really dude, if you start with "sample.badwords" then don't just change to "sample.classes". It's another term.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview