AlliedModders

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

olari9 07-26-2013 06:54

register_clcmd
 
register_clcmd("amx_banmenu", "cmdSSmenu", ADMIN_BAN, "- displays ban menu")
If the line looks like this, then "cmdSSmenu" will be created or it will be called?

TheDS1337 07-26-2013 07:17

Re: register_clcmd
 
I don't know too much about how this works, but I guess it will be called, it's something like:
Code:
public client_command(id) {     static cmd[32];     read_args(cmd, charsmax(cmd));         if (equal(cmd, "amw_banmenu"))     {         if (get_user_flags(id) & ADMIN_BAN)         {                       cmdSSmenu(id);         }     } } public cmdSSmenu(id) { }

olari9 07-26-2013 07:32

Re: register_clcmd
 
Okey thanks :)

ConnorMcLeod 07-26-2013 08:40

Re: register_clcmd
 
It's not exactly like this, cmdSSmenu is called for every player who type command in his console.
You have to check admin access then.

You have to check with cmd_access :

PHP Code:

public plugin_init()
{
    
register_clcmd("amx_banmenu""cmdSSmenu"ADMIN_BAN"- displays ban menu");
}

// here, accessLevel is ADMIN_BAN because it has been registered like this, and as long as you don't change it in configs/cmdaccess.ini
public cmdSSmenu(idaccessLevelcommandIndex)
{
    if( 
cmd_access(idaccessLevelcommandIndex0) )
    {
        
// execute code here
    
}
    return 
PLUGIN_HANDLED;


4th arg of cmd_access is the number of arguments required in order to the command can work correctly, command included, so in your case it's 1, but you can pass 0 as well, cmd_access will take in account that number as minimum, so if 1 arg is required, you can pass 0 or 1.

TheDS1337 07-26-2013 08:45

Re: register_clcmd
 
Quote:

Originally Posted by ConnorMcLeod (Post 1999068)
4th arg of cmd_access is the number of arguments required in order to the command can work correctly, command included, so in your case it's 1, but you can pass 0 as well, cmd_access will take in account that number as minimum, so if 1 arg is required, you can pass 0 or 1.

Now I get it, thank you for your explanation :up:

fysiks 07-26-2013 17:39

Re: register_clcmd
 
Quote:

Originally Posted by DeagLe.Studio (Post 1999029)
I don't know too much about how this works, but I guess it will be called, it's something like:
Code:
public client_command(id) {     static cmd[32];     read_args(cmd, charsmax(cmd));         if (equal(cmd, "amw_banmenu"))     {         if (get_user_flags(id) & ADMIN_BAN)         {                       cmdSSmenu(id);         }     } } public cmdSSmenu(id) { }

I don't know how many times you've been told to stop trying to help people but you really need to stop.

olari9 08-12-2013 05:36

Re: register_clcmd
 
Thanks alot guys, it was really heplful :)


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

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