ConsoleCommand Cooldown

Hey guys, does anyone know how one would create a ConCommand Cooldown?
[lua]
function cooldownexample(ply)
ply:ChatPrint(“Wait 5 seconds before doing this again…”)
end
–Cool Down here?
[/lua]
Thanks in advance!

Like, do you want it so they cannot spam it over and over again or do you want it so they can’t use it util they spend a x amount of time on the server?

Spam Control

– snip because chessnut spoon feeds people–

[lua]
concommand.Add(“cmd”, function(client, command, arguments)
– Check if the cooldown has expired.
if ((client.NextCmd or 0) < CurTime()) then
– Tell the player they ran the command.
client:ChatPrint(“You ran command!”)
– Set the cooldown to the current time + 3 seconds (3 seconds into the future)
client.NextCmd = CurTime() + 3
else
– Get the time needed to wait. (Future time - current time = time left)
client:ChatPrint(“You must wait “…(client.NextCmd - CurTime())…” more seconds”)
end
end)
[/lua]

No work, http://gyazo.com/3f5c669f94efa16f4ae7fa2a615eaa4b

Then put a print(client.NextCmd) in there and report back what it prints. You gotta put some effort into debugging

I highly doubt you are a dev if you can’t figure out the smallest things. Do something; debug it like Exho said then report back.

hm okay, so because I haven’t done something before, then didn’t pay much time to read the script; you take the time to imgur my FP name and tag then write 25 words, which probably took someone like you a minute just because I didn’t write “print(client.NextCmd)” Okay, Can you please take your insecurities some where else? I’m trying to learn over here.

If your trying to learn, don’t have people spoon feed you. Ask them to give you functions then learn how they work. Copying and pasting is NOT a way to learn. Also, a minute? You can upload a picture with lightshot under 10 seconds and then posting it + the text would take about 20 seconds.

Guys, play nice. Can’t hate on a guy for trying to learn. Who knows, maybe he’s never debugged with that method? Don’t assume that just cause he’s a Dev means he knows it already, people develop different things, and sometimes don’t know some fields.

He has dev in his title. Also, why not just ask for the function? If he knows basic lua, he should be able to figure out how the function works just by the wiki or someone telling him the args for that function.

“Hey guys, does anyone know how one would create a ConCommand Cooldown?”
I didn’t ask for the full code, I asked for how to start it, don’t go bitching about me getting something that I didn’t even want.

Chessnut gave you the code, and without debugging it, you reported it didn’t work.

cmd is a command registered in the engine. Did you even try changing the command name?

it doesnt work because cmd already exists dummy.

learn to debug kid.

change the “cmd” to “faggots” and it works fine.

[editline]10th October 2014[/editline]

] find cmd
“cmd”

  • Forward command to server.

[editline]10th October 2014[/editline]


] cmd 
loaded
] cmd
loaded
] cmd 
loaded
] waoz
cmd ran
You ran command!
] waoz
cmd ran
You ran command!
] waoz
cmd ran
You must wait 2.4927215576172 more seconds
] waoz
cmd ran
You must wait 1.8252258300781 more seconds


Why not create more shit threads like this? http://forum.facepunch.com/showthread.php?t=1427917

If you can’t take it, don’t dish it out.

I dont know how you would manage to debug anything in Lua without using Print…

there’s where your wrong, I always know people on face punch are complete ass holes, I can “take it”.