Dcmd command
#1

Hi All,

I made a 10-command for police officers but i have a problem with 2 codes.
pawn Код:
dcmd_10(playerid,params[])
{
    new reportid,id;
    if(gTeam[playerid]!=TEAM_COP)
    {
        SendClientMessage(playerid,COLOR_RED,"This Command is only for Law Enforcement!");
        return 1;
    }
    if(reportid > 99 || reportid < 0)
    {
        SendClientMessage(playerid,COLOR_RED,"Invalid Code!");
        return 1;
    }
    if(HasSendedRadioCode[playerid]>1)
    {
        SendClientMessage(playerid,COLOR_RED,"Please wait before Sending a Police Code again!");
        return 1;
    }
    if(reportid ==25 || reportid ==75)
    {
        if(sscanf(params, "du", reportid,id))
        {
            SendClientMessage(playerid,COLOR_RED,"USAGE: /10 [25/75] [playerid]");
            return 1;
        }
        if(IsPlayerConnected(id) && id != INVALID_PLAYER_ID && id != playerid)
        {
            SendPlayerRadioCrimeCode(playerid,reportid,id);
            HasSendedRadioCode[playerid]=15;
            return 1;
        }
        else
        {
            SendClientMessage(playerid,COLOR_RED,"This Player is not connected");
            return 1;
        }
       
    }
    else
    {
        if(sscanf(params, "d", reportid))
        {
            SendClientMessage(playerid,COLOR_RED,"USAGE: /10 [0-99]");
            return 1;
        }
        SendPlayerRadioCrimeCode(playerid,reportid,-1);
        HasSendedRadioCode[playerid]=15;
    }
    return 1;
}
Code 25 and 75 is for using on other players.
But when i do like /10 25 3 it sends the message to id -1.
How can i fix this?

Admigo
Reply
#2

What message is being sent to ID -1? The "SendPlayerRadioCrimeCode" message? Can we please see that function?
Reply
#3

Because You have not defined it.
You can make Like :-
if(reportid > 0 || reportid < 10)
if(reportid > 10 || reportid < 20)
Like this....
Reply
#4

You need to use sscanf above the reportid checks or it's just going to be 0 the entire time...
Reply
#5

Quote:
Originally Posted by [ABK]Antonio
Посмотреть сообщение
You need to use sscanf above the reportid checks or it's just going to be 0 the entire time...
How can i make that you need to enter /10 25 (playerid) & /10 75 (playerid) and the other codes just /10 (code)
Reply
#6

Everything works fine with this code:
pawn Код:
dcmd_10(playerid,params[])
{
    new reportid,id;
    if(gTeam[playerid]!=TEAM_COP)
    {
        SendClientMessage(playerid,COLOR_RED,"This Command is only for Law Enforcement!");
        return 1;
    }
    if(reportid > 99 || reportid < 0)
    {
        SendClientMessage(playerid,COLOR_RED,"Invalid Code!");
        return 1;
    }
    if(HasSendedRadioCode[playerid]>0)
    {
        SendClientMessage(playerid,COLOR_RED,"Please wait before Sending a Police Code again!");
        return 1;
    }
    if(sscanf(params, "du", reportid,id)&& reportid ==25 || sscanf(params, "du", reportid,id)&& reportid ==75)
    {
        SendClientMessage(playerid,COLOR_RED,"USAGE: /10 [25/75] [playerid]");
        return 1;
    }
    if(IsPlayerConnected(id) && id != INVALID_PLAYER_ID && id != playerid)
    {
        SendPlayerRadioCrimeCode(playerid,reportid,id);
        HasSendedRadioCode[playerid]=15;
        return 1;
    }
    else
    {
        SendClientMessage(playerid,COLOR_RED,"This Player is not connected or is yourself");
        return 1;
    }
    if(sscanf(params, "d", reportid)&& reportid !=25 && sscanf(params, "d", reportid)&& reportid !=75)//errorline
    {
        SendClientMessage(playerid,COLOR_RED,"USAGE: /10 [0-99]");
        return 1;
    }
    SendPlayerRadioCrimeCode(playerid,reportid,-1);
    HasSendedRadioCode[playerid]=15;
    return 1;
}
Only i have an error that i want to have fixed:
Код:
acnr_lv2.pwn(27698) : warning 225: unreachable code
I know the command has a strange combination of the sscanf and this strange combination let the command work but i want to fix the error.

Admigo
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)