Forum

> > CS2D > Scripts > Health Script Smart Peoples Needed :D
Forums overviewCS2D overview Scripts overviewLog in to reply

English Health Script Smart Peoples Needed :D

3 replies
To the start Previous 1 Next To the start

old Health Script Smart Peoples Needed :D

KaBooMa
User Off Offline

Quote
Ok so...Im working on a script and i im not super duper pro at lua...atleast not no more..ive used it for cs2d only and havent used it in a year so here is my script..Can you tell me how to stop it from saying attempt to perform arithmetic on Boolean. I know its cause its adding 1 to the player(id,'health') but how do i fix this?

Spoiler >

old Re: Health Script Smart Peoples Needed :D

DannyDeth
User Off Offline

Quote
lol, it is your 'super duper clever' ( [/sarcasm] ) use* of brackets.
1
2
3
4
5
for id=1,32 do
	if player(id,"exists")
		parse("sethealth "..id.." "..(player(id,"health")+1))
	end
end
This also stops you form trying to heal players that aren't there.

old Re: Health Script Smart Peoples Needed :D

Apache uwu
User Off Offline

Quote
Ah health regeneration.

If I may, this has a delay timer to make it even more realistic.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
addhook("ms100","_ms100")
addhook("hit","_hit")

v_delay=20 --20 = 2 seconds
t_wait={}

function _hit(id)
	t_wait[id]=0
end

function _ms100()
	if #t_wait~=0 then
		for key,value in pairs(t_wait) do
			t_wait[key]=t_wait[key]+1
				if t_wait[key]>=v_delay then
					parse("sethealth "..key.." "..player(key,"health")+1)
				end
			end
		end
	end
end

So if a player is not hit for 2 seconds he will quickly regenerate.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview