AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Say command optimization (https://forums.alliedmods.net/showthread.php?t=188984)

Liverwiz 07-02-2012 11:43

Say command optimization
 
I have a plugin that handles a bunch of say commands. One of these commands requires reading the entire say string. My question is, is it best to look for the designated commands within the say handler, or to register all say commands before the one that reads the entire string?

Code:

        register_clcmd("say /pm", "cmdPMmenu")
        register_clcmd("say /block", "cmdBlock", 0, "/block <nick>")
        register_clcmd("say /pageadmin", "pageAdmin", 0, "Pages all admins")
        register_clcmd("say", "cmdPM", 0, "Private Message: !<nick> <message>")

The way i figure it is that it'll be faster for the VM to grab the commands right out of the chat box and then forward it directly to the command function, rather than my code looking through it each time. What say you, AM?

Exolent[jNr] 07-02-2012 11:50

Re: Say command optimization
 
You should register say commands with the /command if they don't have arguments.
Otherwise, you would need to register the say and say_team commands and parse the said string.

Also,
Quote:

Originally Posted by Liverwiz (Post 1741240)
Code:

register_clcmd("say /block", "cmdBlock", 0, "/block <nick>")

That won't work. It will only hook saying /block, and not /block Exolent.

Liverwiz 07-02-2012 11:59

Re: Say command optimization
 
Quote:

Originally Posted by Exolent[jNr] (Post 1741247)
You should register say commands with the /command if they don't have arguments.
Otherwise, you would need to register the say and say_team commands and parse the said string.

Thank you! That's what i figured, i just thought i should ask before i release some bass ackwards code and get chewed out for it. :P

Quote:

Originally Posted by Exolent[jNr] (Post 1741247)
Also,
That won't work. It will only hook saying /block, and not /block Exolent.

HA! Thanks for that! Saved me 10 minutes of testing.

p.s. why would i ever want to /block Exolent? He's too smart! Like wikipedia for pawn.

fysiks 07-02-2012 19:12

Re: Say command optimization
 
Quote:

Originally Posted by Liverwiz (Post 1741254)
Thank you! That's what i figured, i just thought i should ask before i release some bass ackwards code and get chewed out for it. :P

Testing prevents you from doing that if you test it completely.


All times are GMT -4. The time now is 15:16.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.