Forum

> > CS2D > Scripts > attempt to index global a number value...?
Forums overviewCS2D overview Scripts overviewLog in to reply

English attempt to index global a number value...?

13 replies
To the start Previous 1 Next To the start

old Re: attempt to index global a number value...?

Ajmin
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
timeonsrv = {} ----nw this variable is only for a particular player. if u dnt set table i mean same like what u have done
("timeonsrv = 0")  then this variable is public! (a number value) 

addhook("join","j")
function j(id)
timeonsrv[id]=0
end

addhook("second","timesec")
function timesec()
for id=1,32 do  ----second hook doesnt have any value for"id"  so we will set value for "id" in this way!
  timeonsrv[id] = timeonsrv[id] + 1
end
end
edited 3×, last 21.12.14 07:04:39 pm

old Re: attempt to index global a number value...?

prosuWANTED
User Off Offline

Quote
Hmm... still doesnt work.
it says attempt to perform arithmetc on field '?'

1
2
3
4
5
6
7
8
9
10
11
12
13
timeonsrv = {}

addhook("join","j")
function j(id)
timeonsrv[id]=0
end

addhook("second","timesec")
function timesec()
for id=1,32 do
  timeonsrv[id] = timeonsrv[id] + 1
end
end

old Re: attempt to index global a number value...?

eledah
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
timeonsrv = {}
addhook("second","_second")
addhook("join","_join")

for id = 1, 32 do
	timeonsrv[id] = 0
end

function _join(id)
	timeonsrv[id] = 0
end

function _second()
	for id = 1, 32 do
	  timeonsrv[id] = timeonsrv[id] + 1
	end
end

old Re: attempt to index global a number value...?

Joni And Friends
User Off Offline

Quote
I mean this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
test={}
addhook("join","j")
function j(id)
       test[id]=0
end

addhook("second","s")
function s()
for id=1,32 do
         if player(id,"exists") then
               test[id]=test[id]+1
        end
  end
end
This will make a error because cs2d lua hook second faster than cs2d lua hook join sometime
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview