Forum

> > CS2D > Scripts > How can I insert a value inside this matrix?
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch How can I insert a value inside this matrix?

4 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt How can I insert a value inside this matrix?

BrunoRZ
User Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
function CreateBST()
	BSoldier = {}
	for bl = 1,32 do
		BSoldier[bl] = {}
		for bn = 1,2 do
			BSoldier[bl][bn] = 0
		end
	end
end

This is what I do to create the matrix and to set the initial value of it's elements as 0.
And I did this to change the value of one element:
1
2
3
4
5
6
source = 1
b = (string.sub(msg,12))
	if player(b,'exists') then
		BSoldier[b][1] = source
	end
end

The line 4 in the second code results in this error: attempt to call global 'BSoldier' (a nil value).
I used print(source), print(b) and print(BSoldier[b][1]) to make sure that all of them had any integer value before reaching line 4, and they do... What should I do in order to correctly insert the 'source' value in 'BSoldier[b][1]'?
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht