Forum

> > CS2D > Scripts > 2 errors: Showing points and delayed heal
Forums overviewCS2D overview Scripts overviewLog in to reply

English 2 errors: Showing points and delayed heal

7 replies
To the start Previous 1 Next To the start

old 2 errors: Showing points and delayed heal

Nori-chan
User Off Offline

Quote
Hello guys!

I'm trying to create 2 things via script:
1 - Something that will show my points in the HUD
2 - Delay Heal (After 5 seconds without taking damage, you will heal 1 HP per 0,1 second (+10 HP per second)

Here, I will show to you guys each script

1 -
Spoiler >


The XP part is working, it was made to show to you every time that you kill someone or capture a flag, you get 100 points

The problem on the XP show: I can't get it to work, every time that i try it there's an error on the console:

LUA ERROR: sys/lua/autorun/classes.lua:67: ')' expected near 'Points'

PS: The line 67 is the line 24 on the spoiler
PSS: the "XPP" was made to show and calculate my points (eg. After every kill - XPP = XPP + 1)


The second error
2-
Spoiler >


What I tried here:
- On the function MOHII, if you have 100HP or more, the timer will be 0 (the timer is HHP). If you have less than 100HP, when the timer reaches 5 seconds, the HPP(the quantity of HP that will be healed) will be 1.

The function MOHIT is working normaly (if I replace the HPP with 1, it will work, but without delay)

When I use both, there's no console error and even after 5 seconds, I'm not being healed.

Thank you guys for helping me!

old Re: 2 errors: Showing points and delayed heal

Cure Pikachu
User Off Offline

Quote
I made a health regeneration script for my CO-OP map some time ago, so this is no problem.
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
-- All values that are per-player NEEDS to be a table - No apparent alternatives.
healdelay = {}
healtimer = {}

for a = 1, 32 do
	healdelay[a] = 0
	healtimer[a] = 0
end

healstartin = 50 -- Start healing after x * 100 ms without taking damage
healfreq = 1 -- Delay between heals in x * 100 ms

addhook("ms100","healing")
function healing()
	for _, id in ipairs(player(0,"tableliving")) do
		if player(id,"health") < player(id,"maxhealth") then
			healdelay[id] = healdelay[id] + 1
			if healdelay[id] >= healstartin 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

addhook("hit","resetheal")
addhook("spawn","resetheal")
addhook("die","resetheal")
addhook("leave","resetheal")
function resetheal(id)
	healdelay[id] = 0
	healtimer[id] = 0
end

old Re: 2 errors: Showing points and delayed heal

Nori-chan
User Off Offline

Quote
user Cure Pikachu has written
I made a health regeneration script for my CO-OP map some time ago, so this is no problem.
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
-- All values that are per-player NEEDS to be a table - No apparent alternatives.
healdelay = {}
healtimer = {}

for a = 1, 32 do
	healdelay[a] = 0
	healtimer[a] = 0
end

healstartin = 50 -- Start healing after x * 100 ms without taking damage
healfreq = 1 -- Delay between heals in x * 100 ms

addhook("ms100","healing")
function healing()
	for _, id in ipairs(player(0,"tableliving")) do
		if player(id,"health") < player(id,"maxhealth") then
			healdelay[id] = healdelay[id] + 1
			if healdelay[id] >= healstartin 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

addhook("hit","resetheal")
addhook("spawn","resetheal")
addhook("die","resetheal")
addhook("leave","resetheal")
function resetheal(id)
	healdelay[id] = 0
	healtimer[id] = 0
end


I tested it, but it's giving an error:
LUA ERROR: attempt to call a nil value

old Re: 2 errors: Showing points and delayed heal

Cure Pikachu
User Off Offline

Quote
More >

Works from my side. I don't know what went wrong with your side.

old Re: 2 errors: Showing points and delayed heal

Nori-chan
User Off Offline

Quote
user Cure Pikachu has written
More >

Works from my side. I don't know what went wrong with your side.


I really don't know why it's not working here, so i'm gonna make another one based on yours (If you give me permission, but i'm not going to release, It's just for personal use)

EDIT: Nevermind, I'ts working here. Thank you Pikachu, Gonna add you as a coder here (even if I not release this, I will still have a "Good poeple" list

And VADemon, thank you again, and adding you to the list
edited 2×, last 02.03.13 06:12:49 am
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview