Forum
CS2D Scripts More than 250hpMore than 250hp
8 replies 1
P.S. Check Blazz`s script for hp. You must keep in mind that turrets decrease zombies hp before script hp will be deleted
edited 1×, last 28.02.11 09:48:29 pm
you need to create a variable that will change as a function of hook hit
1
2
3
4
5
6
2
3
4
5
6
addhook("hit","_hit") function _hit(p,s,w,h,a) if player_health > 0 then player_health = player_health - h; end; end;
edited 2×, last 01.03.11 12:28:17 am
can someone make for me example it easier than blazz's
EDIT: i get this error when i use that hook
1
2
2
if player_health > 0 then LUA ERROR: sys/lua/test2.lua:151: attempt to compare number with table
1
if player_health[id] > 0 then
i add what my script have
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
addhook("spawn","humanspawnz") function humanspawnz(id) if (player(id,"team")==2) then zm_health[id] = 0 dmg_factor[id] = math.random(0, 30) flamesec[id] = 0 zm_health_set[id] = 0 randspeed[id] = 0 eaten[id] = 0 randminus[id] = 0 end end addhook("spawn","update") function update(id) zm_knock[id] = math.random(0, 3) flamesec[id] = 0 advsec[id] = 0 flamed[id] = 0 milsec[id] = 0 flamedsecond[id] = 0 speedmodadv[id] = 0 randspeed[id] = 0 randminus[id] = 0 end addhook("hit","hits") function hits(id,source) if player(id,"team")==1 and player(id,"team")~=player(source,"team") then if player(source,"y")-16>player(id,"y") then parse("setpos "..id.." "..player(id,"x").." "..-zm_knock[id]+player(id,"y")) elseif player(source,"y")+16<player(id,"y") then parse("setpos "..id.." "..player(id,"x").." "..zm_knock[id]+player(id,"y")) end if player(source,"x")-16>player(id,"x") then parse("setpos "..id.." "..-zm_knock[id]+player(id,"x").." "..player(id,"y")) elseif player(source,"x")+16<player(id,"x") then parse("setpos "..id.." "..zm_knock[id]+player(id,"x").." "..player(id,"y")) end end end addhook("spawn","updatezm") function updatezm(id) if (player(id,"team")==1) then zm_health[id] = math.random(1000, 4000) zm_health_set[id]=zm_health_set[id]+zm_health[id] zm_speed[id] = 2 zm_knock[id] = math.random(0, 3) flamesec[id] = 0 advsec[id] = 0 flamed[id] = 0 milsec[id] = 0 flamedsecond[id] = 0 speedmodadv[id] = 0 zm_health_set[id] = 0 randspeed[id] = 0 randminus[id] = 0 parse('hudtxt2 '..id..' 3 "©255000000HEALTH: '..zm_health[id]..'" 17 430') end end addhook("startround","setct") function setct() local i for i = 1, 32 do if player(i,"team")==1 then parse("makect "..i) end end end addhook("ms100","hudtxts") function hudtxts(id) for h = 1, #player(0,'table') do if (player(h,"team")==1) then parse('hudtxt2 '..h..' 3 "©200000000HEALTH: '..zm_health[h]..'" 17 430') end end end addhook("hit","_hit") function _hit(p,s,w,h,a) if player_health[id] > 0 then player_health = player_health - h; end; end;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function initArray2(f,v) 	local cmd={} 	for c=1,f do 		cmd[c]=v 	end 	return cmd end player_health=initArray2(32,0) addhook("spawn","sethealth") function sethealth(id) 	player_health[id]=1000 --set your own value here end addhook("hit","ow") function ow(id,src,_,dmg) 	if (player_health[id]>=dmg) then 		player_health[id]=player_health[id]-dmg 		return 1 	else 		return 0 	end end1
Should work.
1