Raised This Month: $ Target: $400
 0% 

register_concmd


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hyphen
Senior Member
Join Date: Aug 2011
Old 06-15-2012 , 08:06   register_concmd
Reply With Quote #1

If proper argument does not being pass while executing a command "Command Info" should be printed, but I need to manually check the argument count and print message. Kindly correct me with my following code snippet.

Code:
register_concmd("amx_cmd", "FnCommands", ADMIN_IMMUNITY, "Command Info")

public FnCommands(id, level, cid)
{
	if(!cmd_access(id, level, cid, 1))
		return PLUGIN_HANDLED
	
	if(read_argc() != 2)
	{
		console_print(id, "Usage: Command Info")
		return PLUGIN_HANDLED
	}
}

Last edited by hyphen; 06-15-2012 at 08:08.
hyphen is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 06-15-2012 , 08:08   Re: register_concmd
Reply With Quote #2

cmd_access already do that. Just change 1 to 2.
__________________
<VeCo> is offline
hyphen
Senior Member
Join Date: Aug 2011
Old 06-15-2012 , 08:09   Re: register_concmd
Reply With Quote #3

OOPS. I got it. Need to change this if(!cmd_access(id, level, cid, 1)) to if(!cmd_access(id, level, cid, <no of expected arguments>))

Am I correct, got it after I posted. LOL.
hyphen is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 06-15-2012 , 08:11   Re: register_concmd
Reply With Quote #4

Yes. It's 2 because the first argument is the command itself and then the second is the real command argument that should be passed to work.
__________________

Last edited by <VeCo>; 06-15-2012 at 08:12.
<VeCo> is offline
hyphen
Senior Member
Join Date: Aug 2011
Old 06-15-2012 , 08:13   Re: register_concmd
Reply With Quote #5

And if I want the command to accept 2 or more arguments then it should be 3 or more
hyphen is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 06-15-2012 , 08:15   Re: register_concmd
Reply With Quote #6

Quote:
Originally Posted by hyphen View Post
And if I want the command to accept 2 or more arguments then it should be 3 or more
Yes.
__________________
<VeCo> is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 06-15-2012 , 13:44   Re: register_concmd
Reply With Quote #7

PHP Code:
register_concmd("amx_cmd""FnCommands"ADMIN_IMMUNITY"<Name | #ID>")

public 
FnCommands(idlevelcid)
{
    if(!
cmd_access(idlevelcid2))    // 1 = Command, 2 = <Param>
        
return PLUGIN_HANDLED //if called, autoshow the usage message: usage: amx_cmd <Name | #ID> passed in register_concmd info
  

Ps. if no paramters, use:

PHP Code:
if(!cmd_access(idlevelcid1
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 06-15-2012 at 13:45.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
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 06:07.


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