Forum

> > CS2D > Scripts > Time Count Down
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Time Count Down

3 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Time Count Down

StrikerD2000
BANNED Off Offline

Zitieren
hello guys i just need a script like have time 1 minute
example if player pressed f2 then
60
after 1 sec
59
after 1 sec
58
after 1 sec
57
after 1 sec
56...
and like that
hope you understand me
i just want it to do something

alt Re: Time Count Down

Baloon
GAME BANNED Off Offline

Zitieren
This is a very easy script, even newbies can made it.

Learn Lua at:
http://www.lua.org/manual/5.1/manual.html
http://cs2d.com/help.php?cat=all
http://cs2d.com/help.php?hookcat=all
http://cs2d.com/help.php?luacat=all

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
countdown = {}

for id = 1, 32 do
  countdown[id]=0
end

addhook("second","secondhook")
function secondhook()
  for _, id in ipairs(player(0,"table")) do
    if countdown[id]>0 then
      msg2(id,countdown[id].."..@C")
      countdown[id] = countdown[id]-1
    end
  end
end
To activate,
1
countdown[id]=60
Error? Be specific, send us the log or screenshot the error (on the console)

This is wrong? Be specific, explain more what you want.

alt Re: Time Count Down

Bowlinghead
User Off Offline

Zitieren
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
-- untested, look in your console(^) and POST THE RED LUA ERROR TEXT

local timer
for id = 1, 32 do
	timer[id]=0
end

addhook("serveraction","mySA")
function mySA(id,b)
	if b==1 then -- f2 (2= f3, 3 = f4)
		if (timer[id] > 0) then -- toggle var
			timer[id] = 0
		else
			timer[id] = 60
		end
	end
end	

addhook("second","mySec")
function mySec()
	for k,v in ipairs(player(0,"table")) do
		if timer[id] > 0 then
			msg2(id,"Your personal timer is: "..tostring(timer[id]))
			timer[id] -= 1
		end
	end
end
This code will make a timer for everyone.
When you press F2 this timer will decrease each second by one, starting with 60.
You can also manually disable the counter by pressing F2 again
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht