Forum

> > CS2D > Scripts > In array to sec...
Forums overviewCS2D overview Scripts overviewLog in to reply

English In array to sec...

22 replies
Page
To the start Previous 1 2 Next To the start

old In array to sec...

Mora
User Off Offline

Quote
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

old Re: In array to sec...

Rainoth
Moderator Off Offline

Quote
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..

old Re: In array to sec...

Mora
User Off Offline

Quote
@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 ...

old Re: In array to sec...

Mora
User Off Offline

Quote
@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
edited 1×, last 19.05.14 12:16:38 pm

old Re: In array to sec...

Mora
User Off Offline

Quote
@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...
edited 5×, last 19.05.14 03:57:15 pm

old Re: In array to sec...

Mora
User Off Offline

Quote
@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

old Re: In array to sec...

AlcatrazZ
BANNED Off Offline

Quote
@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

old Re: In array to sec...

Rainoth
Moderator Off Offline

Quote
@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.

old Re: In array to sec...

Mora
User Off Offline

Quote
Oh @user Rainoth: >.>, why did you care about my topics?they make it for me, so my problem is solved, why need talk about?

old Re: In array to sec...

Rainoth
Moderator Off Offline

Quote
Amazing how people have no idea what I'm trying to say. Whatever, just forget it --"
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview