Forum

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

English Table error

4 replies
To the start Previous 1 Next To the start

old Table error

UnkN
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function array(number,value)
	if not value then value = 0 end
	local array = {}
	for i = 1, number do
		array[i]=value
	end
	return array
end
vtct=array(32,{0,0,0,0,0})
addhook("always","vui1")
function vui1()
for id=1,32 do
if player(id,"exists") then
if player(id,"health")<0 then
if si[id]~=0 then
freeimage(si[id])
end
if vtct[id][2]~=0 then
freeimage(vtct[id][2])
end
if vtct[id][4]~=0 then
freeimage(vtct[id][4])
freeimage(vtct[id][5])
end
end
if player(id,"health")>0 then
if vtct[id][1]~=0 and vtct[id][2]== 0 then
vtct[id][2]=image("gfx/gmod/seta.png",60,20,2,id)
end
if vtct[id][1]== 0 and vtct[id][2]~= 0 then
freeimage(vtct[id][2])
end
if vtct[id][3]~=0 and vtct[id][4]== 0 then
vtct[id][4]=image("gfx/gmod/setb.png",100,20,2,id)
vtct[id][5]=image("gfx/sprites/flare1.bmp",0,0,id+132)
imagecolor(vtct[id][5],000,000,255)
imagealpha(vtct[id][5],0.3)
imagehitzone(vtct[id][5],101,-17,-17,33,33)
end
if vtct[id][3]== 0 and vtct[id][4]~= 0 then
freeimage(vtct[id][4])
freeimage(vtct[id][5])
end
if si[id]==0 then
si[id]=image("gfx/gmod/seti.png",20,20,2)
end
end
end
end
end
Why is it only works on one player? Help please.
I tried to change the value of 2(id) players, but it was given only 1(id) player(lua vtct[2][1]=1)
THEME CLOSED.
I FIX ERROR.
edited 1×, last 20.02.13 06:32:34 am

old Re: Table error

Starkkz
Moderator Off Offline

Quote
I think you are using the same table pointer, it will give you the same values if you do that. When you are using the initial array function you may not insert tables, only numbers or strings. The possibble fix would be setting up 5 arrays that would replace these 5 numbers in the array that you made.

old Re: Table error

omg
User Off Offline

Quote
?
i didnt read the code, but u can put tables inside tables...

if theres a problem with referencing tables, its probably because ur using it like pointers. find a tablecopy function somewhere, probably one in forums
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview