YCMD OnPlayerCommandReceived causes flags to not work.
#1

Hello, I am making it so only admins can output certain commands anyway the flag system doesnt seem to be working for me.

Код:
public e_COMMAND_ERRORS:OnPlayerCommandReceived(playerid, cmdtext[], e_COMMAND_ERRORS:success)
{
    if(success != COMMAND_OK) {
        SendClientMessage(playerid, X11_RED, "Error: Unknown message!");
        return COMMAND_OK;        
    }
    return COMMAND_OK;
}
If I remove/comment the code above out, the system works perfectly fine however if I add it back in the commands perform normally when they aren't supposed to.

Код:
forward adminOnPlayerConnect(playerid);
public adminOnPlayerConnect(playerid) {
    unloadPlayerCmds(playerid);
}

adminOnPlayerLogin(playerid) {
    loadPlayerCmds(playerid);
    return 1;
}

isCmdAllowed(playerid, cmdid) {
    new AdminFlags:alevel = AdminFlags:Player[playerid][Admin];
    if(_:(alevel & acmds[cmdid][CmdAFlags]) != 0 && acmds[cmdid][CmdAFlags] != EAdminFlags_None) {
        return 1;
    }
    return COMMAND_UNDEFINED;
}

loadPlayerCmds(playerid) {
    for(new i=0;i<sizeof(acmds);i++) {
        printf("Is Allowed?: %d", isCmdAllowed(playerid, i));
        if(isCmdAllowed(playerid, i) == 1) {
            Command_SetPlayerNamed(acmds[i][ACMDName], playerid, true);
            print("Allowed");
        }
    }
}

unloadPlayerCmds(playerid) {
    for(new i=0;i<sizeof(acmds);i++) {
        Command_SetPlayerNamed(acmds[i][ACMDName], playerid, false);
        printf("CMDName Test: %s", acmds[i][ACMDName]);
    } 
}
Код:
public OnPlayerConnect(playerid) {
    adminOnPlayerConnect(playerid);
    return 1;
}
Код:
enum AdminFlags (<<= 1) {
    EAdminFlags_None = 0,
    EAdminFlags_Basic = 1, 
    EAdminFlags_Refund,
    EAdminFlags_Donations,
    EAdminFlags_ServerManager,
    EAdminFlags_All = -1
};
enum ACmds {
    ACMDName[32],
    AdminFlags:CmdAFlags
};
new acmds[][ACmds] = {
    {"test", EAdminFlags_All}
};

YCMD:test(playerid, params[], help) {
    SendClientMessage(playerid, X11_RED, "Test working, you are admin");
    return 1;
}
Even disabling the CMD with a command still doesnt work. The command will still send.

Код:
YCMD:disabletest(playerid, params[], help) {
    Command_SetPlayerNamed("test", playerid, false);
    SendClientMessage(playerid, X11_WHITE, "CMD:Test disabled");
    return 1;
}
Reply


Messages In This Thread
YCMD OnPlayerCommandReceived causes flags to not work. - by Alex_T - 04.03.2019, 04:09
Re: YCMD OnPlayerCommandReceived causes flags to not work. - by Alex_T - 04.03.2019, 10:50
Re: YCMD OnPlayerCommandReceived causes flags to not work. - by Alex_T - 04.03.2019, 11:14
Re: YCMD OnPlayerCommandReceived causes flags to not work. - by Alex_T - 04.03.2019, 11:42
Re: YCMD OnPlayerCommandReceived causes flags to not work. - by Alex_T - 04.03.2019, 12:06

Forum Jump:


Users browsing this thread: 1 Guest(s)