/acmds Problem
#1

pawn Код:
ICMD:acmds(playerid, params[])
{
    new
        str[1024];

    if(!pInfo[playerid][pAdminLevel]) return 0;
   
    format(str, sizeof(str), CCE_HLDEFAULT"*** LSGB Admin Commands ***\n"CCE_HLGREEN"Your admin level :"CCE_HLPURPLE" [%d - %s]\n\n", pInfo[playerid][pAdminLevel], GetPlayerAdminLevel(playerid));
   
    for(new i = 0; i != pInfo[playerid][pAdminLevel]; ++i)
    {
        if(pInfo[playerid][pAdminLevel] > 1) strcat(str, FWTE_AQUAMARINE"* Admin Level 1 (Trial Moderator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
        else if(pInfo[playerid][pAdminLevel] > 2) strcat(str, FWTE_AQUAMARINE"* Admin Level 2 (Moderator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
        else if(pInfo[playerid][pAdminLevel] > 3) strcat(str, FWTE_AQUAMARINE"* Admin Level 3 (Global Moderator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
        else if(pInfo[playerid][pAdminLevel] > 4) strcat(str, FWTE_AQUAMARINE"* Admin Level 4 (Master Administrator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
        else if(pInfo[playerid][pAdminLevel] > 5) strcat(str, FWTE_AQUAMARINE"* Admin Level 5 (Senior Administrator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
        else if(pInfo[playerid][pAdminLevel] > 6) strcat(str, FWTE_AQUAMARINE"* Admin Level 6 (Lead Administrtaor): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
        else if(pInfo[playerid][pAdminLevel] > 7) strcat(str, FWTE_AQUAMARINE"* Admin Level 7 (Deputy Head Administrator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
        else if(pInfo[playerid][pAdminLevel] > 8) strcat(str, FWTE_AQUAMARINE"* Admin Level 8 (Head Administrator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
        else if(pInfo[playerid][pAdminLevel] > 9) strcat(str, FWTE_AQUAMARINE"* Admin Level 9 (Co-Owner): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
        else if(pInfo[playerid][pAdminLevel] > 10) strcat(str, FWTE_AQUAMARINE"* Admin Level 10 (Founder): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
    }
   
    ShowPlayerDialog(playerid, DIALOG_ACMDS, DIALOG_STYLE_MSGBOX, IE_PRIMARY"LSGB Admin Commands", str, "Okay", "");
    return 1;
}
Comments: I Want for each admin level commands will be listed.
like this, if i am a level 3 admin, level 1, 2, 3 show for me.
if i am a level 5 admin, level 1, 2, 3, 4, 5 listed for me.

- also for Using ICMD instead of CMD:
pawn Код:
#define ICMD:%1(%2) \
            COMMAND:%1(%2)
- No problems at compiling.

Problem: As i posted the code. just level 1 will be listed for me based on my level.
if i am level 3, level 1 will be listed for me 3 times.
Reply
#2

pawn Код:
for(new i = 0; i != pInfo[playerid][pAdminLevel]; ++i)
    {
        if(pInfo[playerid][pAdminLevel] > 1) strcat(str, FWTE_AQUAMARINE"* Admin Level 1 (Trial Moderator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
        else if(pInfo[playerid][pAdminLevel] > 2) strcat(str, FWTE_AQUAMARINE"* Admin Level 2 (Moderator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
        else if(pInfo[playerid][pAdminLevel] > 3) strcat(str, FWTE_AQUAMARINE"* Admin Level 3 (Global Moderator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
        else if(pInfo[playerid][pAdminLevel] > 4) strcat(str, FWTE_AQUAMARINE"* Admin Level 4 (Master Administrator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
        else if(pInfo[playerid][pAdminLevel] > 5) strcat(str, FWTE_AQUAMARINE"* Admin Level 5 (Senior Administrator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
        else if(pInfo[playerid][pAdminLevel] > 6) strcat(str, FWTE_AQUAMARINE"* Admin Level 6 (Lead Administrtaor): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
        else if(pInfo[playerid][pAdminLevel] > 7) strcat(str, FWTE_AQUAMARINE"* Admin Level 7 (Deputy Head Administrator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
        else if(pInfo[playerid][pAdminLevel] > 8) strcat(str, FWTE_AQUAMARINE"* Admin Level 8 (Head Administrator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
        else if(pInfo[playerid][pAdminLevel] > 9) strcat(str, FWTE_AQUAMARINE"* Admin Level 9 (Co-Owner): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
        else if(pInfo[playerid][pAdminLevel] > 10) strcat(str, FWTE_AQUAMARINE"* Admin Level 10 (Founder): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
    }
I dont know if this will fix the problem, but this will fix a small bug that if you're level 3 it will show you commands for level 1 and 2 and doesnt show 3 because you forgot to add or equal.
Reply
#3

Just replace all else-ifs with ifs.
Reply
#4

Quote:
Originally Posted by RajatPawar
Посмотреть сообщение
Just replace all else-ifs with ifs.
This and don't use a loop - you don't need it at all.
Reply
#5

Quote:
Originally Posted by RajatPawar
Посмотреть сообщение
Just replace all else-ifs with ifs.
also, i will need that loop?

EDIT: Fixed, thanks to all.

pawn Код:
if(pInfo[playerid][pAdminLevel] == 1) strcat(str, FWTE_AQUAMARINE"* Admin Level 1 (Trial Moderator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
    if(pInfo[playerid][pAdminLevel] == 2) strcat(str, FWTE_AQUAMARINE"* Admin Level 2 (Trial Moderator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
    if(pInfo[playerid][pAdminLevel] == 3) strcat(str, FWTE_AQUAMARINE"* Admin Level 3 (Trial Moderator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
    if(pInfo[playerid][pAdminLevel] == 4) strcat(str, FWTE_AQUAMARINE"* Admin Level 4 (Trial Moderator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
    if(pInfo[playerid][pAdminLevel] == 5) strcat(str, FWTE_AQUAMARINE"* Admin Level 5 (Trial Moderator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
    if(pInfo[playerid][pAdminLevel] == 6) strcat(str, FWTE_AQUAMARINE"* Admin Level 6 (Trial Moderator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
    if(pInfo[playerid][pAdminLevel] == 7) strcat(str, FWTE_AQUAMARINE"* Admin Level 7 (Trial Moderator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
    if(pInfo[playerid][pAdminLevel] == 8) strcat(str, FWTE_AQUAMARINE"* Admin Level 8 (Trial Moderator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
    if(pInfo[playerid][pAdminLevel] == 9) strcat(str, FWTE_AQUAMARINE"* Admin Level 9 (Trial Moderator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
    if(pInfo[playerid][pAdminLevel] == 10) strcat(str, FWTE_AQUAMARINE"* Admin Level 10 (Trial Moderator): /slap /akill /slay /explode /asay /burn /an(nounce) /spec(off)\n");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)