[Include] Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+)
#39

As we established in a PM conversation, having 0 as the default command flag causes some issues when it comes to checking whether it's an admin command or not. Having it as anything else but 0 seems to works to a certain extent.

I did some further testing and it seems like the default command flag isn't included in commands with flags. The following command can be executed by players but not by administrators:
PHP код:
command(commandscmdidplayeridparams[]) {
    new 
cmdList[512], bool:need_frmt true;
    if(
need_frmt) {
        for(new 
GetTotalCommandCount(); -->= 0;) {
            if(
== cmdid)
                continue;
            if(
GetCommandFlags(i) == 0) {
                new 
cmd[28];
                
GetCommandName(icmd);
                
strcat(cmdListcmd);
                
strcat(cmdList"\n");
            }
        }
        
need_frmt false;
    }
    
Dialog_Show(playeridadmin_commandsDIALOG_STYLE_LISTCOMMUNITY_NAME" - Commands"cmdList"Select""Cancel");
    return 
CMD_SUCCESS;

Probably worth noting that I'm using the following method of checking for admin commands:
PHP код:
public OnPlayerCommandReceived(cmdidplayeridcmdtext[]) {
    new const 
acmdFlags[7] = {CMD_FLAG_PLAYERACMD_LEVEL_MIN_1ACMD_LEVEL_MIN_2ACMD_LEVEL_MIN_3ACMD_LEVEL_MIN_4ACMD_LEVEL_MIN_5ACMD_LEVEL_MIN_DEV};
    if(
cmdid == INVALID_COMMAND_ID) {
        
Player_SendTaggedMessage(playeridTYPE_ERROR"The specified command does not exist! Use /cmds to see all available commands.");
        return 
CMD_FAILURE;
    }
    
printf("Flags:%b AdminLevel:%d AdminFlag:%b"GetCommandFlags(cmdid), Player[playerid][epd_Admin], acmdFlags[Player[playerid][epd_Admin]]);
    
//if(GetCommandFlags(cmdid) != 0 || acmdFlags[Player[playerid][epd_Admin]] != 0) {
    
if(!(GetCommandFlags(cmdid) & acmdFlags[Player[playerid][epd_Admin]])) {
        
Player_SendTaggedMessage(playeridTYPE_ERROR"The specified command is reserved for administrative players.");
        return 
CMD_FAILURE;
    }
    
//}
    
return CMD_SUCCESS;

While the extra check (commented in the code above) works as it should, I wanted to make the default command flag work without needing an extra check. For that, I defined DEFAULT_CMD_FLAG as:
PHP код:
#define CMD_DEFAULT_FLAG    (0b00000000000000000000000000000010)
#include <smartcmd>         // Credits to Yashas        (https://sampforum.blast.hk/showthread.php?tid=619862
I could include my data module first and then use the enumerator CMD_FLAG_PLAYER instead of redeclaring it there:
PHP код:
enum (<<= 1) {
    
CMD_FLAG_ADMIN 1,
    
CMD_FLAG_PLAYER,
    
ACMD_LEVEL_1,
    
ACMD_LEVEL_2,
    
ACMD_LEVEL_3,
    
ACMD_LEVEL_4,
    
ACMD_LEVEL_5,
    
ACMD_LEVEL_DEV
};
#define ACMD_LEVEL_MIN_DEV  ACMD_LEVEL_DEV
#define ACMD_LEVEL_MIN_5    ACMD_LEVEL_5 | ACMD_LEVEL_MIN_DEV
#define ACMD_LEVEL_MIN_4    ACMD_LEVEL_4 | ACMD_LEVEL_MIN_5
#define ACMD_LEVEL_MIN_3    ACMD_LEVEL_3 | ACMD_LEVEL_MIN_4
#define ACMD_LEVEL_MIN_2    ACMD_LEVEL_2 | ACMD_LEVEL_MIN_3
#define ACMD_LEVEL_MIN_1    ACMD_LEVEL_1 | ACMD_LEVEL_MIN_2 
Is it possible to include the default CMD flag in every single command? The only reason why flags are used is to add an extra layer of permissions to a command or am I wrong on that?

While I'm at it, I seem to have another issue with this method of checking. Administrators can utilise commands that are above their rank.

Little sidenote: there's a little typo in one of the examples:
Код:
enum (<<=1)
{
    VIP_CMD = 1,
    RCON_CMD,
    PLAYER_CMD.
    ACMD1,
    ACMD2,
    ACMD3,
    ACMD4,
    ACMD5
}
Reply


Messages In This Thread
Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 23.10.2016, 06:59
Respuesta: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Unrea1 - 23.10.2016, 07:20
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by DevHarden - 23.10.2016, 08:05
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by RaeF - 23.10.2016, 08:29
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 23.10.2016, 08:39
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by ExTaZZ69 - 23.10.2016, 08:58
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Max_Andolini - 23.10.2016, 10:01
Respuesta: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Whyd - 23.10.2016, 10:29
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by oMa37 - 23.10.2016, 10:38
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Max_Andolini - 23.10.2016, 13:35
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by SyS - 23.10.2016, 13:39
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by SecretBoss - 23.10.2016, 13:40
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Max_Andolini - 23.10.2016, 13:59
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by SecretBoss - 23.10.2016, 14:13
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Battallboi - 23.10.2016, 14:38
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Dayvison_ - 24.10.2016, 03:05
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Gammix - 24.10.2016, 03:18
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by CantBeJohn - 24.10.2016, 06:40
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 24.10.2016, 09:34
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by CantBeJohn - 24.10.2016, 15:31
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by SickAttack - 24.10.2016, 20:14
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by PrO.GameR - 24.10.2016, 20:46
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Crayder - 24.10.2016, 21:11
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by PT - 24.10.2016, 21:13
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Crayder - 24.10.2016, 22:06
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 25.10.2016, 09:53
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by HydraHumza - 25.10.2016, 10:02
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by PrO.GameR - 25.10.2016, 16:40
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 25.10.2016, 16:55
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by SickAttack - 25.10.2016, 18:46
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Jayse - 25.10.2016, 20:26
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by PrO.GameR - 25.10.2016, 22:18
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by SickAttack - 25.10.2016, 23:15
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by PrO.GameR - 26.10.2016, 01:36
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Pottus - 26.10.2016, 02:03
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by SickAttack - 26.10.2016, 04:30
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Crayder - 26.10.2016, 05:27
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 26.10.2016, 08:16
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by AndySedeyn - 30.10.2016, 23:07
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Crayder - 30.10.2016, 23:59
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by AndySedeyn - 31.10.2016, 11:13
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 01.11.2016, 05:05
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by JJohnson1 - 01.11.2016, 08:34
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by AndySedeyn - 01.11.2016, 13:11
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 01.11.2016, 13:19
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 04.11.2016, 14:12
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by kurta999 - 06.11.2016, 13:15
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Max_Andolini - 11.11.2016, 19:47
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 12.11.2016, 05:33
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Max_Andolini - 13.11.2016, 15:02
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 14.11.2016, 12:54
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Max_Andolini - 14.11.2016, 13:04
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 17.11.2016, 10:29
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by ReshiramZekrom - 21.11.2016, 18:31
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Konstantinos - 21.11.2016, 18:41
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 22.11.2016, 07:10
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Nero_3D - 11.12.2016, 11:18
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Crayder - 11.12.2016, 16:36
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Nero_3D - 11.12.2016, 20:11
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Crayder - 12.12.2016, 02:01
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 13.12.2016, 07:46
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by zsoolt997 - 16.12.2016, 07:25
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 16.12.2016, 09:52
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by wallee - 11.01.2017, 04:04
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 14.01.2017, 05:02
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 26.04.2017, 09:00
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by AndySedeyn - 26.04.2017, 11:42
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by wallee - 26.04.2017, 13:29
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Jeroen52 - 18.08.2017, 12:13
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by LosHermanos - 18.08.2017, 16:33
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Banditul18 - 23.09.2017, 20:46
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Jeroen52 - 23.09.2017, 20:48
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 01.10.2017, 09:41
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by m4karow - 01.10.2017, 15:44
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 05.12.2017, 04:54
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Jeroen52 - 05.12.2017, 19:51
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 20.12.2017, 06:38
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Jeroen52 - 20.12.2017, 08:01
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 21.12.2017, 02:41
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Yashas - 25.12.2017, 09:32
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by DeNCHiK01 - 18.05.2018, 09:24
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) - by Verc - 18.05.2018, 11:55

Forum Jump:


Users browsing this thread: 12 Guest(s)