Forum

> > CS2D > Scripts > Script [REQUEST]
Forums overviewCS2D overview Scripts overviewLog in to reply

English Script [REQUEST]

4 replies
To the start Previous 1 Next To the start

old Script [REQUEST]

baRD
User Off Offline

Quote
Hi everybody, I've been wondering how to make a script that regen's your health at a certain time...

Example:
Spoiler >

If someone could send me one, I would highly appriciate that...
Thanks ...

old Re: Script [REQUEST]

Ajmin
User Off Offline

Quote
Same what @user Talented Doge: said.
cs2d gives you a variety of time hooks like second,minute,ms100.
You can use any. For this case second hook would work like a charm.

1
2
3
4
5
6
7
8
9
10
11
12
timing = {}
triggerseconds = 40

addhook("second","seconds")
function seconds()
	for id=1,32 do 
	timing[id]=timing[id]+1
		if timing[id]==triggerseconds then
			bla bla bla bla bla
		end
	end
end
edited 2×, last 31.07.17 05:03:38 pm

old Re: Script [REQUEST]

Cure Pikachu
User Off Offline

Quote
I pulled this from one of my map scripts, is this it?
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
healdelay = {}
healtimer = {}
healdelaysetting = 25 -- Amount of 100ms before HP starts regenerating
healfreq = 2 -- Delay in between regens (in 100ms intervals)

addhook("join","healzero")
addhook("die","healzero")
function healzero(id)
	healdelay[id] = 0
	healtimer[id] = 0
end

addhook("ms100","heal")
function heal()
	for _, id in ipairs(player(0,"tableliving")) do
		if player(id,"health") < player(id,"maxhealth") then
			healdelay[id] = healdelay[id] + 1
			if healdelay[id] >= healdelaysetting then
				healtimer[id] = healtimer[id] + 1
				if healfreq < 1 then
					healfreq = 1
				end
				if healtimer[id] >= healfreq then
					parse("sethealth "..id.." "..player(id,"health")+1)
					healtimer[id] = 0
				end
			end
		else
			healdelay[id] = 0
			healtimer[id] = 0
		end
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview