Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-2

Can somebody help me? Cooldown script.

Asked by 11 years ago

Can somebody help me? I've been attempting to do this but it wont work. So I want a script so if you say "heal/", it will heal you, but if you say it too much it will cooldown. Does anyone know how to do that to prevent spam?

2 answers

Log in to vote
1
Answered by
3rdblox 30
11 years ago

Sorry, this site isn't for requesting scripts to be made for you.

0
That's not an answer. Wrongmistake 0 — 11y
Ad
Log in to vote
1
Answered by 11 years ago

Never request scripts, by the way I am nice today: You can make a timer that start after the player chatted "heal/" like this:

01local timer = 10 -- At how many seconds the timer will start
02local timerStarted = false -- Has the time started?
03function heal()
04    -- Your heal code, inside it put this
05    startTimer()
06end
07 
08function startTimer()
09    timerStarted = true
10    while timer > 0 do
11        timer = timer - 1
12        wait(1) -- Wait 1 second before decrease the timer again, IT WILL NOT FINISH THE FUNCTION UNTIL THE LOOP HAS FINISHED!
13    end
14    timerStarted = false
15    timer = 10 -- Resetting the timer, because the loop has finished
16end

Ok we added something that checks if the timer Started or not, now we need to modify this:

1function heal()
2    -- Your heal code
3    startTimer()
4end

Into this

1function heal()
2    if timerStarted then
3        stopSpam()
4    else
5        -- Your heal code
6        startTimer()
7    end
8end

This simply check if the player healed while the timer has started or not, but we need to add the last and missing function: the stopSpam().... OOH it's sooooo hard! No joke:

1function stopSpam()
2    -- What will the game do to the player? Send a message? Create a gui? Or just banning him?
3    print("A player used the 'heal/' command while his timer started!") -- Simply print to the output the error I wrote
4end

The last thing is: you need to make sure that you call "heal()" inside the command function/script, example IN METALANGUAGE!:

1if player chatted "heal/" then
2    call stopSpam -- or just "stopSpam()"
3end

It should work, the code hasn't been tested, PM me if you encounter any problem!

0
O_O That's confusing reading it all. Idk where to put all of that, do I just add it all together? Wrongmistake 0 — 11y
0
Yes, put those in one script, be careful and read the last thing paragraf alessandro112 161 — 11y

Answer this question