Forum

> > CS2D > Scripts > Fragcount error
Forums overviewCS2D overview Scripts overviewLog in to reply

English Fragcount error

5 replies
To the start Previous 1 Next To the start

old Fragcount error

Alistaire
User Off Offline

Quote
So I'm using a classesscript with a fragcount, but the fragcount doesn't work:

Lua Error has written
LUA ERROR: sys/lua/medieval mod.lua:417: attempt to perform arithmetic on field '?' (a nil value)


This is the error line:

1
2
3
function MM.killcount(id)
	fragcount[id][MM.class[id]]=fragcount[id][MM.class[id]]+1
end

and all the lines with the same fragcount[id] thing:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function initArray2(f,v)
	local array = {}
	for c = 1, f do
		array[c] = v
	end
	return array
end
----
fragcount=initArray2(32,initArray2(7,0))
----
Every single class has fragcount stuff;
----
if (fragcount[id][MM.class[id]]<10) then
	class stuff
end

Now I don't know what the error actually means. Help plz?

old Re: Fragcount error

Apache uwu
User Off Offline

Quote
Try printing.

1
print(fragcount[id][MM.class[id]])

Either fragcount[id][MM.class[id]] or MM.class[id] is nil.

old Re: Fragcount error

palomino
User Off Offline

Quote
What if a human player kills you? Maybe it's the bot AI Lua conflicting with your Lua?

old Re: Fragcount error

Alistaire
User Off Offline

Quote
That is a possibility, since the bots don't seem to choose a class..

I don't know, maybe the math.random thing for bots doesn't work.

----

Yes, human players don't have this problem.

old Re: Fragcount error

EngiN33R
Moderator Off Offline

Quote
The problem might be the bots not choosing any class, I think. Just put this into a/the spawn hook:
1
2
3
if (player(id,"bot")) then
MM.class[id]=math.random(1,7)
end
Or however many there are classes in your script.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview