Problem with /onduty command
#1

Why does my script return this if no one is on duty?

pawn Код:
____________Admins_On_Duty____________
Unknown Command
And if there is a user on duty
pawn Код:
____________Admins_On_Duty____________
User_Name: Level 7 Admin
Unknown Command
pawn Код:
CMD:onduty(playerid, params[])
    {
        SendClientMessage(playerid, COLOR_LIGHTSALMON, "____________Admins_On_Duty____________");
        new totalonduty = 0;
        for(new i = 0; i < MAX_PLAYERS+1; i++)
        {
            if(pInfo[i][Admin] > 1){
                if(aduty[i]){
                    totalonduty = totalonduty+1;
                    new aname[MAX_PLAYER_NAME];
                    new alevel = pInfo[i][Admin];
                    new line[128];
                    GetPlayerName(i, aname, MAX_PLAYER_NAME);
                    format(line, sizeof(line), "%s: Level %i Admin", aname, alevel);
                    SendClientMessage(playerid, COLOR_LIGHTSALMON, line);
                }
            }
        }
       
        if(totalonduty == 0){
            SendClientMessage(playerid, COLOR_RED, "There are no admins on duty.");
        }
        SendClientMessage(playerid, COLOR_RED, "_________________________________________");
        return 1;

    }
Reply
#2

pawn Код:
CMD:onduty(playerid, params[])
    {
        SendClientMessage(playerid, COLOR_LIGHTSALMON, "____________Admins_On_Duty____________");
        new totalonduty = 0;
        for(new i = 0; i < MAX_PLAYERS+1; i++)
        {
            if(pInfo[i][Admin] > 1){
                if(aduty[i] == 1)//= 1{
                    totalonduty = totalonduty+1;
                    new aname[MAX_PLAYER_NAME];
                    new alevel = pInfo[i][Admin];
                    new line[128];
                    GetPlayerName(i, aname, MAX_PLAYER_NAME);
                    format(line, sizeof(line), "%s: Level %i Admin", aname, alevel);
                    SendClientMessage(playerid, COLOR_LIGHTSALMON, line);
                }
            }
        }
       
        if(totalonduty == 0){
            SendClientMessage(playerid, COLOR_RED, "There are no admins on duty.");
        }
        SendClientMessage(playerid, COLOR_RED, "_________________________________________");
        return 1;

    }
i have edited
Reply
#3

Eth, where is your edit?
what did you edit?
explain please.
Reply
#4

Quote:
Originally Posted by AhmedMohamed
Посмотреть сообщение
Eth, where is your edit?
what did you edit?
explain please.
his old cmd:
pawn Код:
CMD:onduty(playerid, params[])
    {
        SendClientMessage(playerid, COLOR_LIGHTSALMON, "____________Admins_On_Duty____________");
        new totalonduty = 0;
        for(new i = 0; i < MAX_PLAYERS+1; i++)
        {
            if(pInfo[i][Admin] > 1){
                if(aduty[i]){
                    totalonduty = totalonduty+1;
                    new aname[MAX_PLAYER_NAME];
                    new alevel = pInfo[i][Admin];
                    new line[128];
                    GetPlayerName(i, aname, MAX_PLAYER_NAME);
                    format(line, sizeof(line), "%s: Level %i Admin", aname, alevel);
                    SendClientMessage(playerid, COLOR_LIGHTSALMON, line);
                }
            }
        }
       
        if(totalonduty == 0){
            SendClientMessage(playerid, COLOR_RED, "There are no admins on duty.");
        }
        SendClientMessage(playerid, COLOR_RED, "_________________________________________");
        return 1;

    }
what i edit is aduty[i] his old one was : aduty[i] and i changed it to aduty[i] == 1 because this 1 will know if the player is on duty or not.
Reply
#5

Quote:
Originally Posted by AhmedMohamed
Посмотреть сообщение
Eth, where is your edit?
what did you edit?
explain please.
Exactly what I was going to say. It defeats the purpose of solving a problem if you just copy/paste a new code. You gotta explain what you changed and why it was wrong before.
Reply
#6

by the way there is no deference between
Код:
aduty[i]
and
Код:
aduty[i] == 1
because if you type the first one so you mean that it's equal 1
and this won't fix his problem
Reply
#7

Quote:
Originally Posted by Eth
Посмотреть сообщение
his old cmd:
pawn Код:
CMD:onduty(playerid, params[])
    {
        SendClientMessage(playerid, COLOR_LIGHTSALMON, "____________Admins_On_Duty____________");
        new totalonduty = 0;
        for(new i = 0; i < MAX_PLAYERS+1; i++)
        {
            if(pInfo[i][Admin] > 1){
                if(aduty[i]){
                    totalonduty = totalonduty+1;
                    new aname[MAX_PLAYER_NAME];
                    new alevel = pInfo[i][Admin];
                    new line[128];
                    GetPlayerName(i, aname, MAX_PLAYER_NAME);
                    format(line, sizeof(line), "%s: Level %i Admin", aname, alevel);
                    SendClientMessage(playerid, COLOR_LIGHTSALMON, line);
                }
            }
        }
       
        if(totalonduty == 0){
            SendClientMessage(playerid, COLOR_RED, "There are no admins on duty.");
        }
        SendClientMessage(playerid, COLOR_RED, "_________________________________________");
        return 1;

    }
what i edit is aduty[i] his old one was : aduty[i] and i changed it to aduty[i] == 1 because this 1 will know if the player is on duty or not.
That didn't change anything. Still get the same result. If it helps, aduty[playerid] is set to false/true.
Reply
#8

but I am not sure
pawn Код:
CMD:onduty(playerid, params[])
    {
        SendClientMessage(playerid, COLOR_LIGHTSALMON, "____________Admins_On_Duty____________");
        new totalonduty = 0;
        for(new i = 0; i < MAX_PLAYERS+1; i++)
        {
            if(pInfo[i][Admin] > 1){
                if(aduty[i] == 1)
                   {
                    totalonduty = totalonduty+1;
                    new aname[MAX_PLAYER_NAME];
                    new alevel = pInfo[i][Admin];
                    new line[128];
                    GetPlayerName(i, aname, MAX_PLAYER_NAME);
                    format(line, sizeof(line), "%s: Level %i Admin", aname, alevel);
                    SendClientMessage(playerid, COLOR_LIGHTSALMON, line);
                   }
                }
            }
        }
       
        if(totalonduty == 0){
            SendClientMessage(playerid, COLOR_RED, "There are no admins on duty.");
        }
        SendClientMessage(playerid, COLOR_RED, "_________________________________________");
        return 1;

    }
I think the problem is here :
pawn Код:
if(aduty[i] == 1)//= 1{
I made it
pawn Код:
if(aduty[i] == 1)
{
//here is the content
}
Reply
#9

another error:
pawn Код:
totalonduty = totalonduty+1;
make it
pawn Код:
totalonduty++
because X never equal X + 1
Reply
#10

Quote:
Originally Posted by AhmedMohamed
Посмотреть сообщение
another error:
pawn Код:
totalonduty = totalonduty+1;
make it
pawn Код:
totalonduty++
because X never equal X + 1
Yeah, that is the way I had it before. But it doesn't change the error.

Quote:
Originally Posted by AhmedMohamed
Посмотреть сообщение
but I am not sure
pawn Код:
CMD:onduty(playerid, params[])
    {
        SendClientMessage(playerid, COLOR_LIGHTSALMON, "____________Admins_On_Duty____________");
        new totalonduty = 0;
        for(new i = 0; i < MAX_PLAYERS+1; i++)
        {
            if(pInfo[i][Admin] > 1){
                if(aduty[i] == 1)
                   {
                    totalonduty = totalonduty+1;
                    new aname[MAX_PLAYER_NAME];
                    new alevel = pInfo[i][Admin];
                    new line[128];
                    GetPlayerName(i, aname, MAX_PLAYER_NAME);
                    format(line, sizeof(line), "%s: Level %i Admin", aname, alevel);
                    SendClientMessage(playerid, COLOR_LIGHTSALMON, line);
                   }
                }
            }
        }
       
        if(totalonduty == 0){
            SendClientMessage(playerid, COLOR_RED, "There are no admins on duty.");
        }
        SendClientMessage(playerid, COLOR_RED, "_________________________________________");
        return 1;

    }
I think the problem is here :
pawn Код:
if(aduty[i] == 1)//= 1{
I made it
pawn Код:
if(aduty[i] == 1)
{
//here is the content
}
That code that you changed was what that other guy sent. The way you have it is how I had it orginally, except it was more like
pawn Код:
if(aduty[i])
{

}
because aduty isn't set to 1 when they are on duty, and 0 when they are off duty, they are set to True and False.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)