Forum

> > CS2D > Scripts > Timer with 2 parameter
Forums overviewCS2D overview Scripts overviewLog in to reply

English Timer with 2 parameter

5 replies
To the start Previous 1 Next To the start

old Timer with 2 parameter

Promaster
User Off Offline

Quote
1
2
3
4
5
6
7
8
function ttfk()
	timer(2000,ttfk2,"5" "5",2)
end

function ttfk2(a,b)
	print(a)
	print(b)
end


Is there possible to make timer with 2 parameter a and b on funktion ttfk2?

old Re: Timer with 2 parameter

Waldin
User Off Offline

Quote
try this edited version of user EnderCrypt's file cs2d Timer2 - easy timer! (take care, it doesn't handle errors)
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
function timer2(d, a, f, c)
	local i = #t2 + 1
	t2[i] = {
		a = a,
		f = f,
		c = c and (c == 0 and -1 or c) or 1
	}
	timer(d, "t2h", i, c)
	return i
end
function freetimer2(i)
	if i then
		if t2[i].c ~= 0 then
			freetimer("t2h", i)
		end
		t2[i] = nil
	else
		for i in pairs(t2) do
			if t2[i].c ~= 0 then
				freetimer("t2h", i)
			end
		end
		t2 = {}
	end
end
t2 = {}
function t2h(i)
	i = tonumber(i)
	t2[i].f(unpack(t2[i].a))
	t2[i].c = t2[i].c - 1
	if t2[i].c == 0 then
		freetimer2(i)
	end
end
local id = timer2(2000, {"5", "5"}, ttfk2, 2)
edited 1×, last 28.05.17 10:22:23 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview