English How to add a delay

2 replies
Goto Page
To the start Previous 1 Next To the start
16.08.18 04:06:49 pm
Up
LiME1516
User
Offline Off
How to make a delay? For example, he wrote and !bandage will command not work for 5 seconds.

Code:
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
16.08.18 05:02:29 pm
Up
Cure Pikachu
User
Offline Off
You know the utsfx sample script?
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
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.
IMG:https://i.imgur.com/5UWPaft.png
IMG:https://i.imgur.com/xpsyQRX.png
16.08.18 07:31:10 pm
Up
LiME1516
User
Offline Off
Wow, thank you very much.
To the start Previous 1 Next To the start