Raised This Month: $ Target: $400
 0% 

Using #define to set command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 05-13-2013 , 01:30   Re: Re: Using #define to set command
Reply With Quote #1

Quote:
Originally Posted by ^SmileY View Post
PHP Code:
stock register_custom_clcmd(const szCommand[],const szFunction[],iFlags 0,const szInfo[]="")
{
    static 
szBuffer[192];

    
formatex(szBuffer,charsmax(szBuffer),"/%s",szCommand);
    
register_clcmd(szBuffer,szFunction,iFlags,szInfo);

    
formatex(szBuffer,charsmax(szBuffer),"%s",szCommand);
    
register_clcmd(szBuffer,szFunction,iFlags,szInfo);

That's redundant lol. So simple and less native calls to simply write the register twice.
Doc-Holiday is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-13-2013 , 04:19   Re: Using #define to set command
Reply With Quote #2

Quote:
Originally Posted by Doc-Holiday View Post
That's redundant lol. So simple and less native calls to simply write the register twice.
I don't see any redundancy in that function. The only thing wrong with it is that it is not registering chat commands like the OP has requested. However, you are correct that it is more native calls than necessary if only trying to register one or two commands. The function was originally designed for dynamically registering say commands. Using it, after fixing it, will change performance negligibly since it's run in plugin_init().
__________________
fysiks is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 05-13-2013 , 06:16   Re: Re: Using #define to set command
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
I don't see any redundancy in that function. The only thing wrong with it is that it is not registering chat commands like the OP has requested. However, you are correct that it is more native calls than necessary if only trying to register one or two commands. The function was originally designed for dynamically registering say commands. Using it, after fixing it, will change performance negligibly since it's run in plugin_init().
What I meant by redundant is that register clcmd already does this with less native calls. Just have to write 2 or 4 depending on what you want to do instead of 4 or 8 native calls
Doc-Holiday is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 05-13-2013 , 12:34   Re: Using #define to set command
Reply With Quote #4

Quote:
Originally Posted by Doc-Holiday View Post
That's redundant lol. So simple and less native calls to simply write the register twice.
const szCommand[] > register_custom_clcmd("test","cmdTest",ADMIN_ CVAR,"<Test command");

Its return a registered commands:

.test, test, and all others commands.

Its no way to use a unique register_cl/srv/cmd native call, to register a different commands with / . ! or others.

If you want to register one per one, use it for now its a simple solution found for others plugins.
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 05-14-2013 , 00:02   Re: Using #define to set command
Reply With Quote #5

Ok. ... I only understood your last sentence. But like they said it's pointless because it's in plugin init so use what ever method works for you

Last edited by Doc-Holiday; 05-14-2013 at 00:03.
Doc-Holiday is offline
Reply



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 16:20.


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