i leave cs2d 2, 3 week ! help me @ @
i want remove some image near player:
Error :
1
attempt to perform arithmetic on filed '?' (a nil value)
create image
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
function create_light(l_x,l_y) 	if l_x and l_y then 		i = i + 1 		save_x[i] = l_x 		save_y[i] = l_y 		l_img[i] = image("gfx/sprites/flare3.bmp",save_x[i],save_y[i],1) 		imagepos(l_img[i],save_x[i],save_y[i],math.random(1,360)) 	end end
remove image
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
addhook("attack","remove") function remove(id) 	if id ~= nil then 		remove_light(id) 	end end function remove_light(id) 	local x = player(id,"x") 	local y = player(id,"y") 	if i then 		if x < (save_x[i] + 16) and x > (save_x[i] - 16) then 			if (y < save_y[i] + 16) and y > (save_y[i] - 16) then 				if l_img[i] ~= nil then 					save_x[i] = nil 					save_y[i] = nil 					freeimage(l_img[i]) 				end 			end 		end 	end end