Thread Tools Display Modes
12-10-12, 09:17 PM   #1
Starix
A Murloc Raider
Join Date: Dec 2012
Posts: 9
Command in second

Hi, firends.

Help me to make Addon which will show how many slash command was entered into chat in 1 seconds by me
For example, 1000 command in seconds.

thx.
  Reply With Quote
12-10-12, 10:33 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I'm not sure I understand what you want.

Do you want an addon that tells you how many times you entered any slash command in the last 1 second, or an addon that runs a slash command in 1 second?

If the first, I'm not sure what the point would be. How fast can you really enter slash commands?
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
12-10-12, 10:59 PM   #3
Starix
A Murloc Raider
Join Date: Dec 2012
Posts: 9
Originally Posted by Phanx View Post
I'm not sure I understand what you want.

Do you want an addon that tells you how many times you entered any slash command in the last 1 second, or an addon that runs a slash command in 1 second?

If the first, I'm not sure what the point would be. How fast can you really enter slash commands?
first.
I want to look how many command I will enter in a seconds.
  Reply With Quote
12-10-12, 11:09 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
.... why? ....
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
12-10-12, 11:16 PM   #5
Starix
A Murloc Raider
Join Date: Dec 2012
Posts: 9
Originally Posted by Seerah View Post
.... why? ....
That you mean?
  Reply With Quote
12-11-12, 12:56 AM   #6
Talyrius
An Onyxian Warder
 
Talyrius's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 363
Originally Posted by Starix View Post
That you mean?
Huh?

Please explain why you need such an addon.
  Reply With Quote
12-11-12, 01:06 AM   #7
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
The obvious answer is why not.

If you have concerns it might be used in some malicious manner then those concerns should be voiced, otherwise if a person is interested in making some whacky addon for their own amusement and you can help, why not?

Edit: I have no idea where to start with such an addon. If there was one out there that needed fixing I might be able to help. I'm still very much in the LUA learning phase.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 12-11-12 at 01:51 AM.
  Reply With Quote
12-11-12, 03:22 AM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
It would be possible to write such an addon, but I'm not going to waste my time. I can't think of any possible way that would be useful. Even the fastest typist in the world cannot enter more than 1-3 slash commands in a single second. The only ways to enter more would be to (1) spam a macro, but I can't think of any slash command where spamming it 1000 times in a single second with a macro would have any benefit at all, or (2) use third-party automation/botting software, which is against the TOS/EULA and nobody here will help you with anything related to that.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
12-11-12, 03:41 AM   #9
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
So you are asuming that by entering Starix means
/comand, press enter, respond. /comand, press enter, respond.

What about:
/comand /comand /comand /comand /comand /comand, press enter (a self test: how many /comands did I type before a second ticked).

Kidding aside, a good and valid reply Phanx, I'll get my Devils Advocate off and head bedside .
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 12-11-12 at 03:53 AM.
  Reply With Quote
12-11-12, 02:18 PM   #10
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,323
I was bored, here's some code.

Lua Code:
  1. local CachedText={};
  2. local function OnShow(self) CachedText[self]=self:GetText(); end
  3. local function OnTextChanged(self) local txt=self:GetText(); if txt~="" then CachedText[self]=txt; end end
  4.  
  5. local Hooked={};
  6. hooksecurefunc("ChatEdit_ActivateChat",function(editbox)
  7.     if not Hooked[editbox] then
  8.         editbox:HookScript("OnShow",OnShow);
  9.         editbox:HookScript("OnTextChanged",OnTextChanged);
  10.         OnShow(editbox);--  Aready shown by the time this runs
  11.  
  12.         Hooked[editbox]=true;
  13.     end
  14. end);
  15.  
  16. local Count,Start=0,GetTime();
  17. hooksecurefunc("ChatEdit_SendText",function(editbox)
  18.     local cmd,now=((CachedText[editbox] or ""):match("^/%S+") or ""):upper(),GetTime();
  19.     if IsSecureCmd(cmd) or hash_SlashCmdList[cmd] or hash_EmoteTokenList[cmd] then
  20. --      Our reset command will run this too
  21.         if Count<0 then Count=0; return; end
  22.         if Count<1 then Start=now; end
  23.  
  24.         Count=Count+1;
  25.         local runtime=now-Start;
  26.         print(("%d commands run in %0.2f seconds. (%0.2f commands per second)"):format(Count,runtime,Count/runtime));
  27.     end
  28. end);
  29.  
  30. function SlashCmdList.SLASHCOUNT_RESET()
  31. --  Our hook will finish the reset
  32.     Count=-1;
  33. end
  34. SLASH_SLASHCOUNT_RESET1="/slashcountreset";
  35. SLASH_SLASHCOUNT_RESET2="/screset";
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 12-17-12 at 04:04 AM.
  Reply With Quote
12-15-12, 06:58 PM   #11
Starix
A Murloc Raider
Join Date: Dec 2012
Posts: 9
Originally Posted by SDPhantom View Post
I was bored, here's some code.

Lua Code:
  1. local count,start=0,GetTime();
  2. hooksecurefunc("ChatEdit_SendText",function(editbox)
  3.     local txt,now=editbox:GetText(),GetTime();
  4.     if hash_SlashCmdList[(txt:match("^/%S+") or ""):upper()] then
  5. --      Our reset command will run this too
  6.         if count<=0 then start=now; end
  7.         if count<0 then count=0; return; end
  8.  
  9.         count=count+1;
  10.         local runtime=now-start;
  11.         print(("%d commands run in %0.2f seconds. (%0.2f commands per second)"):format(count,runtime,count/runtime));
  12.     end
  13. end);
  14.  
  15. function SlashCmdList.SLASHCOUNT_RESET()
  16. --  Our hook will finish the reset
  17.     count=-1;
  18. end
  19. SLASH_SLASHCOUNT_RESET1="/slashcountreset";
  20. SLASH_SLASHCOUNT_RESET2="/screset";
thanks

but

Lua Code:
  1. hash_SlashCmdList[(txt:match("^/%S+") or ""):upper()]

return nil.
  Reply With Quote
12-16-12, 01:27 PM   #12
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,323
It only does that when the command you entered isn't in the table. If that's the case, the command doesn't exist in the normal slash command list and shouldn't increment the counter.

I modified the code posted above to accept secure commands and emotes, regular chat is omitted. I forgot there was a global function Blizzard provided to check if a slash command is a secure command. As for the emotes, that's just something that was overlooked when I posted previously.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
12-16-12, 02:16 PM   #13
Starix
A Murloc Raider
Join Date: Dec 2012
Posts: 9
Originally Posted by SDPhantom View Post
It only does that when the command you entered isn't in the table. If that's the case, the command doesn't exist in the normal slash command list and shouldn't increment the counter.

I modified the code posted above to accept secure commands and emotes, regular chat is omitted. I forgot there was a global function Blizzard provided to check if a slash command is a secure command. As for the emotes, that's just something that was overlooked when I posted previously.
cmd return nil
  Reply With Quote
12-17-12, 04:06 AM   #14
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,323
Turns out, Blizzard is clearing the editbox of its contents before I get a chance to capture it. I added in some hooking to support caching the text as the user types it in so we have our copy to work with that Blizzard can't screw up at the moment. I reupdated the code already posted above to the new version.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Command in second

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off