Forum

> > CS2D > Scripts > sethealth with always hook
Forums overviewCS2D overview Scripts overviewLog in to reply

English sethealth with always hook

2 replies
To the start Previous 1 Next To the start

old sethealth with always hook

prosuWANTED
User Off Offline

Quote
For some reason, sethealth doesnt work for me .

1
2
3
4
5
6
7
addhook("always","big1")

function big1(id)
  if (player(id,"health")>1)
    parse('sethealth "..id.." 1')
  end
end

old Re: sethealth with always hook

ohaz
User Off Offline

Quote
Your problem is that the always hook does not have any parameters - but you're trying to use it with one.
You should rather write it without the id parameter and get your id parameter by looping over the existing players table

old Re: sethealth with always hook

prosuWANTED
User Off Offline

Quote
i tried that:
1
2
3
4
5
6
7
8
9
function big1()
  for id=1,32 do
    if(player(id,"exists")) then
      if (player(id,"health")>1)
        parse('sethealth "..id.." 1')
      end
    end
  end
end
... but that still didn't work.
Am i doying something wrong?
EDIT:
i forgot to add "then" :D.
It works now.
Thanks!
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview