• ConsoleCommand Cooldown
    18 replies, posted
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?
[QUOTE=shadowslayer9;46194879]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?[/QUOTE] 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]
[QUOTE=Chessnut;46194964][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][/QUOTE] No work, [url]http://gyazo.com/3f5c669f94efa16f4ae7fa2a615eaa4b[/url]
Then put a print(client.NextCmd) in there and report back what it prints. You gotta put some effort into debugging
[IMG]http://i.imgur.com/rZ1ZkEr.png[/IMG] 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.
[QUOTE=shadowslayer9;46195364][IMG]http://i.imgur.com/rZ1ZkEr.png[/IMG] 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.[/QUOTE] 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.
[QUOTE=SwikCoder;46195422]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.[/QUOTE] 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 [B]NOT[/B] 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.
[QUOTE=xthenarwhalx;46196282]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.[/QUOTE] [I]He has dev in his title.[/I] 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.
[QUOTE=shadowslayer9;46196349][I]He has dev in his title.[/I] 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.[/QUOTE] "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.
[QUOTE=SwikCoder;46196487]"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.[/QUOTE] Chessnut gave you the code, and without debugging it, you reported it didn't work.
[url]https://developer.valvesoftware.com/wiki/Console_Command_List[/url] cmd is a command registered in the engine. Did you even try changing the command name?
[QUOTE=SwikCoder;46195149]No work, [url]http://gyazo.com/3f5c669f94efa16f4ae7fa2a615eaa4b[/url][/QUOTE] 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] [code]] 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 [/code]
[QUOTE=SwikCoder;46195422]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.[/QUOTE] Why not create more shit threads like this? [url]http://facepunch.com/showthread.php?t=1427917[/url] If you can't take it, don't dish it out.
[QUOTE=xthenarwhalx;46196282]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.[/QUOTE] I dont know how you would manage to debug anything in Lua without using Print...
[QUOTE=Blasteh;46197954]Why not create more shit threads like this? [url]http://facepunch.com/showthread.php?t=1427917[/url] If you can't take it, don't dish it out.[/QUOTE] there's where your wrong, I always know people on face punch are complete ass holes, I can "take it".
Sorry, you need to Log In to post a reply to this thread.