Forum

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

English Timer error

1 reply
To the start Previous 1 Next To the start

old Timer error

LifeIsCat27
User Off Offline

Quote
i wanted to add some timer but it always errors
a timer is important because of :
do you ever see an attilery firing all at once? its gonna be funny if you see that

could anybody help me with the timer problems?

this is some part of the script
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
addhook("say","ASRequest")
function ASRequest(id,txt,x,y)
     local s = totable(txt)
     local cmd = (s[1])
     if cmd == "!sd" then
          if SD[id] == true then
               ASX[id] = tonumber(s[2])
               ASY[id] = tonumber(s[3])
               PACK[id] = tonumber(s[4])
               if ASX[id]>0 and ASY[id]>0 and ASX[id] < map"xsize" and ASY[id] < map"ysize" then
                    if PACK[id] == 1 then
                         msg2(id,"©000255000Confirmed")
                         msg2(id,"©000255000Supply Drop At X:"..ASX[id].." Y:"..ASY[id].." Package:"..PACK[id].." ")
                         timer(5000,"supplydrop",id)
                         SD[id] = false
                    else
                         msg2(id,"©255000000Denied, Pack Id Doesnt Exist!")
                    end
               else
                    msg2(id,"©255000000Denied, Coordinate is out of map!")
               end
          else
               msg2(id,"©255000000Denied, You don't have Supply Drop!")
          end
     return 1
     end
end

function supplydrop(id)
     if PACK[id] == 1 then
          parse("spawnitem 32 "..ASX[id].." "..ASY[id]) -- Line 79
     end
end

console says:
LUA ERROR: sys/lua/BattleSupport.lua:79: attempt to concatenate field '?' (a nil value)

old Re: Timer error

EngiN33R
Moderator Off Offline

Quote
Change your supplydrop function to:

1
2
3
4
5
6
function supplydrop(id)
id=tonumber(id)
if PACK[id] == 1 then
parse("spawnitem 32 "..ASX[id].." "..ASY[id]) -- Line 79
end
end

The timer provides string arguments. Player IDs are number, which is why I added that quick line that transforms ID into a number.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview