Raised This Month: $ Target: $400
 0% 

Say command optimization


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 07-02-2012 , 11:43   Say command optimization
Reply With Quote #1

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?
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-02-2012 , 11:50   Re: Say command optimization
Reply With Quote #2

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 View Post
Code:
register_clcmd("say /block", "cmdBlock", 0, "/block <nick>")
That won't work. It will only hook saying /block, and not /block Exolent.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 07-02-2012 , 11:59   Re: Say command optimization
Reply With Quote #3

Quote:
Originally Posted by Exolent[jNr] View Post
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.

Quote:
Originally Posted by Exolent[jNr] View Post
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.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-02-2012 , 19:12   Re: Say command optimization
Reply With Quote #4

Quote:
Originally Posted by Liverwiz View Post
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.
Testing prevents you from doing that if you test it completely.
__________________
fysiks is offline
Reply


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

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

Forum Jump


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


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