[HELP] Takedrugs command !
#1

I have a problem . I edited everything good with no errors , but in game i am a cop and if i tipe /takedrugs it keeps saying : "Error: Cops only for this feature!" , and i puted myself cop sking , cop team and the rank 1 . What's the problem ! Here's the command :

pawn Код:
if(strcmp(cmd, "/takedrugs", true) == 0 || strcmp(cmd, "/td", true) == 0)
    {
    format(string, sizeof(string), "Command: %s: %s", sendername2, cmdtext);
    SendCmdMessage(COLOR_YELLOW, string);
    if (PlayerLoggedIn[playerid] != 1)
    {
        SendClientMessage(playerid, COLOR_RED, "Error: You are not logged in");
        return 1;
    }
    if(gTeam[playerid] == TEAM_COP && PlayerInfo[playerid][pRank] == 1 || gTeam[playerid] == TEAM_ARMY && PlayerInfo[playerid][pRank] == 2)
    {
        SendClientMessage(playerid, COLOR_WHITE, "Error: Cops only for this feature!");
        return 1;
    }
        tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, COLOR_ORANGE, "Usage: /takedrugs [playerid]");
        return 1;
    }
        giveplayerid = strval(tmp);
    if(IsPlayerConnected(giveplayerid))
    {
        format(string, sizeof(string), "Command: %s: %s", sendername2, cmdtext);
        SendCmdMessage(COLOR_YELLOW, string);
        if(giveplayerid != INVALID_PLAYER_ID)
        {
            if (ProxDetectorS(8.0, playerid, giveplayerid))
            {
                format(string, sizeof(string), "* You have taken away %s's Drugs.", giveplayer);
                SendClientMessage(playerid, COLOR_YELLOW, string);
                format(string, sizeof(string), "* Officer %s has taken away your Drugs.", sendername);
                SendClientMessage(giveplayerid, COLOR_YELLOW, string);
                PlayerInfo[giveplayerid][pDrugs] = 0;
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "Error: That player is not near you !");
                return 1;
            }
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "Error: That player is Offline !");
        return 1;
        }
    }
Help me please !
Reply
#2

pawn Код:
if(gTeam[playerid] == TEAM_COP && PlayerInfo[playerid][pRank] == 1 || gTeam[playerid] == TEAM_ARMY && PlayerInfo[playerid][pRank] == 2)
    {
        SendClientMessage(playerid, COLOR_WHITE, "Error: Cops only for this feature!");
        return 1;
    }
There you are telling it TO NOT WORK for cops (and army)

this is what you need to do:

pawn Код:
if(gTeam[playerid] != TEAM_COP && PlayerInfo[playerid][pRank] == 1 || gTeam[playerid] != TEAM_ARMY && PlayerInfo[playerid][pRank] == 2)
    {
        SendClientMessage(playerid, COLOR_WHITE, "Error: Cops only for this feature!");
        return 1;
    }
Reply
#3

Ok . It helped . But i want to modifiy another thing : I don't want if i tipe /takedrugs 0 , to take my drugs myself . Can you do that ?
Reply
#4

BUMP !!!!
Reply
#5

pawn Код:
if(giveplayerid == playerid)
{
     SendClientMessage(playerid, COLOR_WHITE, "Error: You cannot take drugs from yourself.");
     return 1;
}
Reply
#6

Ty it worked . Problem solved !
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)