English Time Count Down

3 replies
Goto Page
To the start Previous 1 Next To the start
19.02.17 01:50:06 pm
Up
StrikerD2000
BANNED
Offline Off
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
@user StrikerD2000 | I love DC
19.02.17 02:50:32 pm
Up
Boolean
GAME BANNED
Offline Off
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

Code:
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,
Code:
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.
19.02.17 06:52:53 pm
Up
StrikerD2000
BANNED
Offline Off
@user Boolean:
thanks
please excuse me cuz i am newbie
@user StrikerD2000 | I love DC
20.02.17 02:23:49 pm
Up
Bowlinghead
User
Offline Off
Code:
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
Share time limited free games here
To the start Previous 1 Next To the start