Help with enums!
#1

I made an enum with all admin commands and require level, then I made a stock to send a message of the cmds.
here are the codes:

Enum:

pawn Код:
enum A_COMMANDS
{
    aCommand[24],
    aLevel
}

new AdminCommands[][A_COMMANDS] = {
{"goto", ADMIN_1},
{"gethere", ADMIN_1},
{"ban", ADMIN_1},
{"kick", ADMIN_1},
{"ajail", ADMIN_1},
{"slap", ADMIN_1},
{"freeze", ADMIN_1},
{"unfreeze", ADMIN_1},
{"mute", ADMIN_1},
{"getcar", ADMIN_1},
{"gotocar", ADMIN_1}
};
Now the stock:

pawn Код:
stock DisplayLevelCommands(playerid, level)
{
    new count = 0, cmds[256];
    SCMEx(playerid, COLOR_LIGHTRED, "Admin Level %d Commands", level);
    for(new i = 0; i < sizeof(AdminCommands); i++)
    {
        if(AdminCommands[i][aLevel] == level)
        {
            format(mstr, sizeof(mstr), " /%s |", AdminCommands[i][aCommand]);
            strcat(cmds, mstr);
            count++;
            if(count == 8)
            {
                strcat(cmds, "\n");
                count = 0;
            }
        }
    }
    SCM(playerid, COLOR_WHITE, cmds);
    return 1;
}

The problem is that when the count is equal to 8, the \n doesn't works the cmds are at the same line.
Picture:



Reply
#2

\n doesnt work in SendClientMessage
Reply
#3

You must separate all the commands into many SCMs.
Reply
#4

This is probably not the best approach to write such function, but it should work.

Код:
stock DisplayLevelCommands(playerid, level)
{
    new count = 0, cmds[128];
    SCMEx(playerid, COLOR_LIGHTRED, "Admin Level %d Commands", level);
    while(count < sizeof(AdminCommands))
    {
        if(AdminCommands[count][aLevel] == level)
        {
            format(mstr, sizeof(mstr), " /%s |", AdminCommands[count][aCommand]);
            strcat(cmds, mstr);
            count++;
            if(count % 8 == 0)
            {
                SCM(playerid, COLOR_WHITE, cmds);
                cmds = "";
            }
        }
    }
    SCM(playerid, COLOR_WHITE, cmds);
    return 1;
}
Reply
#5

Thanks Youarex, I made this one something more comfortable:

pawn Код:
stock DisplayLevelCommands(playerid, level)
{
    new count = 0, cmds[128];
    SCMEx(playerid, COLOR_LIGHTRED, "Admin Level %d Commands", level);
    for(new i = 0; i < sizeof(AdminCommands); i++)
    {
        if(AdminCommands[i][aLevel] == level)
        {
            if(count != 0)
                format(mstr, sizeof(mstr), " /%s ", AdminCommands[i][aCommand]);
            else if(count == 0)
                format(mstr, sizeof(mstr), "> /%s ", AdminCommands[i][aCommand]);
            strcat(cmds, mstr);
            count++;
            if(count == 10 || count != 10 && i == sizeof(AdminCommands)-1)
            {
                SCMEx(playerid, -1, "{C3C3C3}%s", cmds);
                count = 0;
                cmds = "";
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)