SA-MP Forums Archive
Problem in code - 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 in code (/showthread.php?tid=530334)



Problem in code - krytans - 06.08.2014

Hello, I got an error while compiling this command:
pawn Код:
CMD:badge(playerid, params[])
{
    strmid(sendername, PlayerRPName(playerid), 0, MAX_PLAYER_NAME);
    if(PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pMember] == 1)
    {
        if(PlayerInfo[playerid][pPUndercover] == 1)
        {
            switch(PlayerInfo[playerid][pMember])
            {
                case 1: format(string, sizeof(string), "* Officer %s clips their badge on.", sendername);
                case 2: format(string, sizeof(string), "* Agent %s clips their badge on.", sendername);
            }
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            PlayerInfo[playerid][pPUndercover] = 0;
            SetPlayerToTeamColor(playerid);
        }
        else
        {
            switch(PlayerInfo[playerid][pMember])
            {
                case 1: format(string, sizeof(string), "* Officer %s clips their badge off.", sendername);//lspd
                case 2: format(string, sizeof(string), "* Agent %s clips their badge off.", sendername);//fbi
            }
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            PlayerInfo[playerid][pPUndercover] = 1;
            SetPlayerToTeamColor(playerid);
        }
    }
    else
    {
        if(PlayerInfo[playerid][pMember] == 3 || PlayerInfo[playerid][pMember] == 4 || PlayerInfo[playerid][pMember] == 5)
        {
            switch(PlayerInfo[playerid][pMember])
            {
                case 3: format(string, sizeof(string), "* Officer %s clips their badge on.", sendername);//sast
                case 4: format(string, sizeof(string), "* Paramedic %s clips their badge on.", sendername);//fmd
                case 5: format(string, sizeof(string), "* Cadet %s clips their badge on.", sendername);//ng
            }
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            SetPlayerToTeamColor(playerid);
        }
        else
        {
            switch(PlayerInfo[playerid][pMember])
            {
                case 3: format(string, sizeof(string), "* Officer %s clips their badge off.", sendername);
                case 4: format(string, sizeof(string), "* Paramedic %s clips their badge off.", sendername);
                case 5: format(string, sizeof(string), "* Cadet %s clips their badge off.", sendername);
            }
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            SetPlayerToTeamColor(playerid);
        }
    }
    else <<-- here
    {
        SendClientMessage(playerid, COLOR_GRAD2, "   You are not authorized to use that command !");
    }
    return 1;
}
the error is:
Код:
Invalid experission, assumed Zero.
thanks


Re: Problem in code - Stinged - 06.08.2014

Line?


Re: Problem in code - krytans - 06.08.2014

Код:
  else <<--- here
    {
        SendClientMessage(playerid, COLOR_GRAD2, "   You are not authorized to use that command !");
    }
    return 1;
}



Re: Problem in code - AhmedGang - 06.08.2014

pawn Код:
else //that line
    {
        SendClientMessage(playerid, COLOR_GRAD2, "   You are not authorized to use that command !");
    }



Re: Problem in code - ViniBorn - 06.08.2014

Try this
pawn Код:
CMD:badge(playerid, params[])
{
    strmid(sendername, PlayerRPName(playerid), 0, MAX_PLAYER_NAME);
    if(PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pMember] == 1)
    {
        if(PlayerInfo[playerid][pPUndercover] == 1)
        {
            switch(PlayerInfo[playerid][pMember])
            {
                case 1: format(string, sizeof(string), "* Officer %s clips their badge on.", sendername);
                case 2: format(string, sizeof(string), "* Agent %s clips their badge on.", sendername);
            }
            PlayerInfo[playerid][pPUndercover] = 0;
        }
        else
        {
            switch(PlayerInfo[playerid][pMember])
            {
                case 1: format(string, sizeof(string), "* Officer %s clips their badge off.", sendername);//lspd
                case 2: format(string, sizeof(string), "* Agent %s clips their badge off.", sendername);//fbi
            }
            PlayerInfo[playerid][pPUndercover] = 1;
        }
        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        SetPlayerToTeamColor(playerid);
    }
    else if(PlayerInfo[playerid][pMember] == 3 || PlayerInfo[playerid][pMember] == 4 || PlayerInfo[playerid][pMember] == 5)
    {
        if(PlayerInfo[playerid][pPUndercover] == 1)
        {
            switch(PlayerInfo[playerid][pMember])
            {
                case 3: format(string, sizeof(string), "* Officer %s clips their badge on.", sendername);//sast
                case 4: format(string, sizeof(string), "* Paramedic %s clips their badge on.", sendername);//fmd
                case 5: format(string, sizeof(string), "* Cadet %s clips their badge on.", sendername);//ng
            }
            PlayerInfo[playerid][pPUndercover] = 0;
        }
        else
        {
            switch(PlayerInfo[playerid][pMember])
            {
                case 3: format(string, sizeof(string), "* Officer %s clips their badge off.", sendername);
                case 4: format(string, sizeof(string), "* Paramedic %s clips their badge off.", sendername);
                case 5: format(string, sizeof(string), "* Cadet %s clips their badge off.", sendername);
            }
            PlayerInfo[playerid][pPUndercover] = 1;
        }
        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        SetPlayerToTeamColor(playerid);
    }
    else
        SendClientMessage(playerid, COLOR_GRAD2, "   You are not authorized to use that command !");

    return 1;
}



Re: Problem in code - krytans - 06.08.2014

While using this command [pMember == 3,4 & 5

You are not authorized to use that command