Forum

> > CS2D > Scripts > attempt to index global a number value...?
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

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

13 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

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

Ajmin
User Off Offline

Zitieren
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
3× editiert, zuletzt 21.12.14 19:04:39

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

prosuWANTED
User Off Offline

Zitieren
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

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

eledah
User Off Offline

Zitieren
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

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

Joni And Friends
User Off Offline

Zitieren
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
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht