English Script to show health

4 replies
Goto Page
To the start Previous 1 Next To the start
28.05.14 07:09:55 pm
Up
superpegamento
User
Offline Off
Hi, us
i need to lower the hp when attacking, he hud stays at 100, greetings

Code:
1
2
3
4
addhook("spawn" , "HP")
function HP(id)
parse('hudtxt 3 "©255255000HP: '..player(id,"health")..'" 100 10')
end
28.05.14 07:12:35 pm
Up
Pirates killer
User
Offline Off
It will give you your hp , not the enemy hp ..
file cs2d [PK]Admin script V2 (32) Newbie scripting.
28.05.14 07:48:45 pm
Up
Rainoth
Moderator
Offline Off
Code:
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.
Code:
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
28.05.14 07:54:50 pm
Up
TopNotch
User
Offline Off
Better use cs2d cmd hudtxt2.
Update the hudtxt2 using the cs2d lua hook hit hook.
Code:
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
28.05.14 08:15:10 pm
Up
Rainoth
Moderator
Offline Off
Oh right, didn't notice that. I take it for a given
To the start Previous 1 Next To the start