AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   register_concmd (https://forums.alliedmods.net/showthread.php?t=187590)

hyphen 06-15-2012 08:06

register_concmd
 
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
        }
}


<VeCo> 06-15-2012 08:08

Re: register_concmd
 
cmd_access already do that. Just change 1 to 2.

hyphen 06-15-2012 08:09

Re: register_concmd
 
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.

<VeCo> 06-15-2012 08:11

Re: register_concmd
 
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.

hyphen 06-15-2012 08:13

Re: register_concmd
 
And if I want the command to accept 2 or more arguments then it should be 3 or more

<VeCo> 06-15-2012 08:15

Re: register_concmd
 
Quote:

Originally Posted by hyphen (Post 1729172)
And if I want the command to accept 2 or more arguments then it should be 3 or more

Yes.

^SmileY 06-15-2012 13:44

Re: register_concmd
 
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



All times are GMT -4. The time now is 06:07.

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