SA-MP Forums Archive
Problem with /onduty command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with /onduty command (/showthread.php?tid=509450)



Problem with /onduty command - Nathan_Taylor - 26.04.2014

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;

    }



Re: Problem with /onduty command - Eth - 26.04.2014

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


Re: Problem with /onduty command - AhmedMohamed - 26.04.2014

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


Re: Problem with /onduty command - Eth - 26.04.2014

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.


Re: Problem with /onduty command - Nathan_Taylor - 26.04.2014

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.


Re: Problem with /onduty command - AhmedMohamed - 26.04.2014

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


Re: Problem with /onduty command - Nathan_Taylor - 26.04.2014

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.


Re: Problem with /onduty command - AhmedMohamed - 26.04.2014

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
}



Re: Problem with /onduty command - AhmedMohamed - 27.04.2014

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


Re: Problem with /onduty command - Nathan_Taylor - 27.04.2014

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.