katursis / Pawn.CMD

🚀 Plugin-powered command processor for SA:MP server
MIT License
119 stars 13 forks source link

Assigning flags #29

Closed Fairuz-Afdhal closed 4 years ago

Fairuz-Afdhal commented 4 years ago

I'm migrating from izcmd to PawnCMD and I'm interested to use flags instead of normal if checks. I'm having some problem here:

public OnPlayerCommandReceived(playerid, cmd[], params[], flags)
{
    if (flags && !(flags & p_Permissions[ playerid ] ) )
    {
        return SendError( playerid, "You don't have access to this command." ), 0;
    }
    return 1;
}

I want to pass the command if it doesn't have any flags, but this still doesn't work, I don't want to manually assign every single command I have right now My commands:

CMD:cmds( playerid, params[ ] )
{
    return 1;
}

flags:ownercmds( CMD_OWNER )
CMD:ownercmds( playerid, params[ ] )
{
    return 1;
}

How I'm assigning the flags:

hook OnPlayerlogin( playerid )
{
    if( p_AdminLevel[ playerid ] == 6 ) p_Permissions[ playerid ] = CMD_OWNER | CMD_COUNCIL | CMD_LEAD | CMD_SENIOR | CMD_GENERAL | CMD_TRIAL;
    else if( p_AdminLevel[ playerid ] == 5 ) p_Permissions[ playerid ] = CMD_COUNCIL | CMD_LEAD | CMD_SENIOR | CMD_GENERAL | CMD_TRIAL;
    else if( p_AdminLevel[ playerid ] == 4 ) p_Permissions[ playerid ] = CMD_LEAD | CMD_SENIOR | CMD_GENERAL | CMD_TRIAL;
    else if( p_AdminLevel[ playerid ] == 3 ) p_Permissions[ playerid ] = CMD_SENIOR | CMD_GENERAL | CMD_TRIAL;
    else if( p_AdminLevel[ playerid ] == 2 ) p_Permissions[ playerid ] = CMD_GENERAL | CMD_TRIAL;
    else if( p_AdminLevel[ playerid ] == 1 ) p_Permissions[ playerid ] = CMD_TRIAL;
    else p_Permissions[ playerid ] = 0;
    return 1;
}

I can access /stats but I can't access /ownercmds.

Fairuz-Afdhal commented 4 years ago

Fixed.