SA-MP Forums Archive
Dcmd 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: Dcmd command (/showthread.php?tid=438886)



Dcmd command - Admigo - 22.05.2013

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


Re: Dcmd command - TheStreetsRP - 22.05.2013

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


Re: Dcmd command - Avi Raj - 23.05.2013

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


Re: Dcmd command - [ABK]Antonio - 23.05.2013

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


Re: Dcmd command - Admigo - 31.05.2013

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)


Re: Dcmd command - Admigo - 18.06.2013

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