Forum

> > CS2D > Scripts > How to add a delay
Forums overviewCS2D overview Scripts overviewLog in to reply

English How to add a delay

2 replies
To the start Previous 1 Next To the start

old How to add a delay

_Lima_
User Off Offline

Quote
How to make a delay? For example, he wrote and !bandage will command not work for 5 seconds.

1
2
3
4
5
6
7
8
9
addhook("say","say_med")
function say_med(id,txt)
	if (txt=="!bandage") or (txt=="!drop bandage") then
		if (player(id,"money")>1999) then
		parse("spawnitem 65 "..player(id,"tilex").." "..player(id,"tiley").."")
		parse("setmoney "..id.." "..player(id,"money")-2000)
		end
	end
end

Admin/mod comment

"my script" is a horrible title. Please try to use less generic titles! Fixed for you. /DC

old Re: How to add a delay

Cure Pikachu
User Off Offline

Quote
You know the utsfx sample script?
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
cooldown = {}

addhook("join","initcooldown")
function initcooldown(id)
	cooldown[id] = 0
end

addhook("leave","removecooldown")
function removecooldown(id)
	cooldown[id] = nil
end

addhook("say","say_med")
function say_med(id,txt)
	if (txt=="!bandage") or (txt=="!drop bandage") then
		local rcd = os.clock() - cooldown[id]
		if rcd > 5 then
			if (player(id,"money")>=2000) then
				parse("spawnitem 65 "..player(id,"tilex").." "..player(id,"tiley"))
				parse("setmoney "..id.." "..player(id,"money")-2000)
				cooldown[id] = os.clock()
			end
		else
			msg2(id,"Command is on a cooldown of "..rcd.." seconds")
		end
	end
end
Something like that.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview