Forum

> > CS2D > Scripts > In array to sec...
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch In array to sec...

22 Antworten
Seite
Zum Anfang Vorherige 1 2 Nächste Zum Anfang

alt In array to sec...

Mora
User Off Offline

Zitieren
Hello us
the title is not correct, eh.
I wanna ask for help me, i made new script, but here is an error, only with this funtion
1
2
3
4
5
addhook("second","se")
function se(id)
hungry[id]=hungry[id]+1
hw(id)
end
without this hook all works perfect, but!
error is:
1
LUA ERROR: sys/lua/heal.lua:33: attempt to perform arithmetic on field '?' (a nil value)
I dont show the full code, but as i said without this hook all works perfect, so maybe some1 can steal it, even if it bad (i mean peoples, who cant make this but wanna it,i dont mean peoples who cant do it and wanna steal... huh?)
thank you

alt Re: In array to sec...

Rainoth
Moderator Off Offline

Zitieren
Honestly, I didn't even read what you wrote to the end...
Just wanted to tell you that "second" hook does not supply id of people so you need to loop it with
1
for _,id in pairs (player(0, "table")) do
Can be "tableliving" if it's for alive people only..

alt Re: In array to sec...

Mora
User Off Offline

Zitieren
@user Rainoth: oh thank you so much , it works, and can it make limit of this hungry? just i need limit 150, but it infinite add hungry points, i dont know how ...

alt Re: In array to sec...

Mora
User Off Offline

Zitieren
@user MikuAuahDark:
1
LUA ERROR: sys/lua/heal.lua:34: attempt to index global 'hunger' (a nil value)

with this:
1
2
3
4
5
6
7
addhook("minute","se")
function se(id)
for _,id in pairs (player(0, "table")) do
hunger[id]=hunger[id]>150 and 150 or hunger[id]+10
hw(id)
end
end
maybe i wrong add this your line you show me?:
1
hunger[id]=hunger[id]>150 and 150 or hunger[id]+10
1× editiert, zuletzt 19.05.14 12:16:38

alt Re: In array to sec...

Mora
User Off Offline

Zitieren
@user MikuAuahDark: also:
second to minute, so it 10, because every second is so fast, but every minute +10 is ok...
Ah hunger :D, oops, my eyes is notwake up, i will replace, thanks
I replace and i add 100, so when my hungry is 100, in next minute i will got 200, but max is 150? Huh?...
Maybe need add this, when this hungry example is 150 maximum, but we have 145, and us hungry every minute get + 15, so it will be not 160, and 150...

Also after 3 minutes i got 251, after+ 1 minute i got 150, +1 minute 251,+1 minute 150, and-INF...
(when i change hungry[id]+101..just for test, what will be if...
5× editiert, zuletzt 19.05.14 15:57:15

alt Re: In array to sec...

Mora
User Off Offline

Zitieren
@user AlcatrazZ: if my hungry is 145 and i add + 15, it will be 155, but not 150 ,but it work and dont add more.
1 sec= 145
2 sec= 155
3 sec= 150
4 sec= 150....etc it will be 150.
also i specialy add second, for fast see that

alt Re: In array to sec...

AlcatrazZ
BANNED Off Offline

Zitieren
@user Mora: Use this code to free this bug!
hunger[id] = hunger[id] >= 150 and 150 or hunger[id] + 10
if hunger[id] > 150 then hunger[id] = 150 end

alt Re: In array to sec...

Rainoth
Moderator Off Offline

Zitieren
@user AlcatrazZ: Really mature. "Needless"? His code wouldn't work without that "Needless" help. It's a mistake that was already made and corrected. You copy the code and end up copying without correcting it.
Zum Anfang Vorherige 1 2 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht