Forum

> > CS2D > Scripts > Script to show health
Forums overviewCS2D overview Scripts overviewLog in to reply

English Script to show health

4 replies
To the start Previous 1 Next To the start

old Script to show health

superpegamento
User Off Offline

Quote
Hi, us
i need to lower the hp when attacking, he hud stays at 100, greetings

1
2
3
4
addhook("spawn" , "HP")
function HP(id)
parse('hudtxt 3 "©255255000HP: '..player(id,"health")..'" 100 10')
end

old Re: Script to show health

Rainoth
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
hp = {}

addhook("spawn" , "HP")
function HP(id)
	hp[id] = 100
	parse('hudtxt 3 "©255255000HP: '..hp[id]..'" 100 10')
end

addhook("hit","HarryPotter")
function HarryPotter(id,s,w,h,a,r)
	if player(id,"team")~=player(s,"team") then--note that you need additional checks if the game contains vip
		hp[id] = hp[id] - h
		parse('hudtxt 3 "©255255000HP: '..hp[id]..'" 100 10')
	end
end

Please make a better title next time and use search. I'm sure you'd find some good scripts you could use to base your own on.

EDIT :
I realised what you want.
1
2
3
4
5
6
7
8
9
addhook("spawn" , "HP")
function HP(id)
	parse('hudtxt 3 "©255255000HP: '..player(id,"health")..'" 100 10')
end

addhook("hit","HarryPotter")
function HarryPotter(id,s,w,h,a,r)
	parse('hudtxt 3 "©255255000HP: '..player(id,"health")..'" 100 10')
end

old Re: Script to show health

TopNotch
User Off Offline

Quote
Better use cs2d cmd hudtxt2.
Update the hudtxt2 using the cs2d lua hook hit hook.
1
2
3
4
5
addhook("hit","_hit")
function _hit(id,source,w)
   parse('hudtxt2 '..source..' 1 "HP ('..player(id,"name")..'): '..player(id,"health")..'" 100 10 0')
   parse('hudtxtalphafade '..source..' 1 2000 0')
end
This will show "HP (enemy's name): his hp".
edited 1×, last 28.05.14 08:20:47 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview