Forum

> > CS2D > Scripts > timer not working
Forums overviewCS2D overview Scripts overviewLog in to reply

English timer not working

6 replies
To the start Previous 1 Next To the start

old timer not working

En-Kay
User Off Offline

Quote
Ok so I made this script when a Dragonlord class says "!spell" he turns into dragon aspect for 9 seconds,if he has 16000 $.After 9 seconds he should return to normal state but the timer doesn't work.Please help me fix this problem.

Here is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
addhook("say","aspect")
function aspect(id,txt)
	if (sample.classes.class[id]==3) then
		if (txt=="!spell") then
			if player(id,"money")==16000 then
				wings=image("gfx/wings.bmp<m>", 1,0,id+200)
				parse ("equip "..id.." 46")
				parse ("setmaxhealth "..id.." 210")
				parse ("setmoney "..id.." -16000")
				msg("Dragonlord has embraced the powers of the Dragon Aspect!")
				timer(9000,"parse",'setmaxhealth "..id.." 175"')
				timer(9000,"parse",'strip "..id.." 46"')
				timer(9000,"freeimage",'wings')
			else
				msg("you don't hav enough mana!")
			end
		end
	end
end

old Re: timer not working

Dousea
User Off Offline

Quote
Try this.
wings = {}

addhook ("say", "aspect")

function aspect (id, text)
	if (sample.classes.class[id] == 3) then
		if (text == "!spell") then
			if (player (id, "money") == 16000) then
				wings[id] = image ("gfx/wings.bmp<m>", 1, 0, 200 + id)
				
				parse ("equip " .. id .. " 46; setmaxhealth " .. id .. " 210; setmoney " .. id .. " -16000", 0)
				
				msg2 (id, "Dragonlord has embraced the power of the Dragon Aspect!@C")
				
				timer (9000, "endaspect", id)
				
				function endaspect (id)
					parse ("setmaxhealth " .. id .. " 175; strip " .. id .. " 46", 0)
					
					freeimage (wings[tonumber (id)])
				end
			else
				msg2 (id, "You do not have enough Mana!")
			end
		end
	end
end
edited 2×, last 29.08.14 01:43:05 pm

old Re: timer not working

En-Kay
User Off Offline

Quote
Timer now works,but when more dragonlords enter aspect form,wings will be removed only from the last one who entered it.

old Re: timer not working

En-Kay
User Off Offline

Quote
No, unfortunately it does not work.But I noticed the whole function endaspect() only works for the last one who went into aspect form.

old Re: timer not working

Dousea
User Off Offline

Quote
OK, now it already fixed. I even test it. Try again. If you keep getting errors, your sources maybe the problem. Just tell what the errors are.

old Re: timer not working

En-Kay
User Off Offline

Quote
You are right, it works.I forgot to add something so it didn't work.I apologise for this misunderstanding.I thank you.

edit:

Is there any way I can add cooldown for this funciton so I can use it again after a minute or so?
edited 1×, last 30.08.14 08:12:49 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview