Forum

> > CS2D > Scripts > table
Forums overviewCS2D overview Scripts overviewLog in to reply

English table

No replies
To the start Previous 1 Next To the start

old closed table

kalis
User Off Offline

Quote
my lua
1
2
3
grass.x = {}
grass.y = {}
grass.img = {}

1
2
3
4
5
6
7
addhook("second","_spawn")
function _spawn()
for i = 1,5 do
     grass.x[i] = math.random(1,30)
     grass.y[i] = math.random(1,30)
     grass.img[i] = image('gfx/city_kalis/grass.bmp',3,2,1)
end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
addhook("attack","cut_grass")
function cut_grass(id)          
          local x = player(id,"x")
          local y = player(id,"y")
          if w == 50 then
               for i = 1,5 do
                    if grass.x[i] > 0 and grass.y[i] > 0 then
                         local dist = math.sqrt((grass.x[i]-x)^2+(grass.y[i]-y)^2)
                         if dist < 30 then
                              if grass.img[i] ~= nil then
                                   grass.x[i] = 0
                                   grass.y[i] = 0
                                   freeimage(grass.img[i])
                                   parse("sv_msg2 "..id.." nice work")
                              end

                         end

                    end
               end
          end

end

Problem is :
grass.x[i],grass.y[i],grass.img[i] !
when i attack on grass [1] but my script free grass.img[1-5]

Admin/mod comment

You'd already asked this in a different thread. /ohaz Rules §2.1 - No needless and/or doubled posts (spam)
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview