Forum

> > CS2D > Scripts > Health script
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Health script

6 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Health script

Marcell
Super User Off Offline

Zitieren
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

alt Re: Health script

Alistaire
User Off Offline

Zitieren
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

alt Re: Health script

Rainoth
Moderator Off Offline

Zitieren
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).

alt Re: Health script

useigor
User Off Offline

Zitieren
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).
1× editiert, zuletzt 23.10.13 16:55:49
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht