Forum

> > CS2D > Scripts > Health script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Health script

6 replies
To the start Previous 1 Next To the start

old Health script

Marcell
Super User Off Offline

Quote
Why isn't work?

I'd like to do that, when player's health goes under 30 the heart.ogg sound plays..

1
2
3
4
5
6
addhook("spawn", "heart")
function heart(id)
	if player(''..id..' '..health..'') < 30
	then parse('sv_sound2 '..id..' sfx/heart.ogg')
	end
end

old Re: Health script

Alistaire
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
addhook('second','_secondHook')

function _secondHook()
	for _, id in pairs(player(0, 'tableliving')) do
		if player(id, 'health')/player(id, 'maxhealth') <= 0.3 then
			parse('sv_sound2 '..id..' sfx/heart.ogg')
		end
	end
end

old Re: Health script

Rainoth
Moderator Off Offline

Quote
1
2
3
4
5
6
addhook("hit","heart")
function heart(id)
	if player(id,"health")<45 then
		parse('sv_sound2 '..id..' sfx/heart.ogg')
	end
end

EDIT : I've been ninja'd
You can't use spawn hook because you spawn with players max health. The check for health doesn't need to be concatenated, you're calling a function 'player' with two arguments (id and value).

old Re: Health script

useigor
User Off Offline

Quote
user Marcell, what is length of your sound? He used % instead of HP. It's means if max HP is 200 then you will hear sound if your health <= 60 HP. For his script, your sound should have lenght = 1 sec (heartbeat).
edited 1×, last 23.10.13 04:55:49 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview