[Quick question] Unreachable code
#1

Hello guys ! I have got this common warning on a few lines
pawn Код:
C:\Archivos de programa\Rockstar Games\GTA San Andreas\SA-MP 0.3b\Server 0.3b\gamemodes\fierroharb.pwn(655) : warning 225: unreachable code
I think it's a easy question, so I doubt it will take much to be solved.
pawn Код:
if(strcmp(cmdtext, "/gotousa", true)==0)
    {
        if(PlayerInfo[playerid][pAdminLevel] > 0)
        {
            SendClientMessage(playerid,COLOR_LIGHTBLUE," You have teleported to America Base");
            SetPlayerPos(playerid,-1347.9703,492.6265,11.1953);
            return 1;
        } ---------------------------> LINE 665
        else
        {
            return SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: You are not an admin !");
        }
        return 1; -----------------------> LINE 770
    }
I know this isn't much but i want a clean script with no warnings or error to avoid more further errors ..
Line 770 has the same warning too
Thanks for help
Reply
#2

Код:
if(strcmp(cmdtext, "/gotousa", true)==0)
    {
        if(PlayerInfo[playerid][pAdminLevel] > 0)
        {
            SendClientMessage(playerid,COLOR_LIGHTBLUE," You have teleported to America Base");
            SetPlayerPos(playerid,-1347.9703,492.6265,11.1953);
            return 1;
        }
        SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: You are not an admin !");
        return 0; 
        }
Reply
#3

pawn Код:
if(strcmp(cmdtext, "/gotousa", true)==0)
    {
        if(PlayerInfo[playerid][pAdminLevel] > 0)
        {
            SendClientMessage(playerid,COLOR_LIGHTBLUE," You have teleported to America Base");
            SetPlayerPos(playerid,-1347.9703,492.6265,11.1953);
            return 1;
        }
        else SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: You are not an admin !");
        return 1;
    }
Reply
#4

Thanks, but i have found other error now ! It's the same warning, just other script

pawn Код:
if(strcmp(cmdtext, "/ban", true)==0)
    {
        new tmp[256];
        tmp = strtok( cmdtext, idx );
        if (!strlen(tmp))
        {
            return SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: /ban");
        }
        if(PlayerInfo[playerid][pAdminLevel] > 0)
        {
            new string[50], string2[50], adminname[MAX_PLAYER_NAME], banname[MAX_PLAYER_NAME];
            GetPlayerName(playerid, adminname, sizeof(adminname));
            GetPlayerName(playerid, banname, sizeof(banname));
            format(string, sizeof(string), " Administrator %s has banned you", adminname);
            format(string2, sizeof(string2), " Player %s has been banned by administrator %s", banname, adminname);
           
            SendClientMessage(playerid,COLOR_LIGHTBLUE,"[ADMIN]: Player banned.");
            SendClientMessage(strval(tmp),COLOR_LIGHTBLUE,"--------------------------------------------");
            SendClientMessage(strval(tmp),COLOR_LIGHTBLUE,string);
            SendClientMessage(strval(tmp),COLOR_LIGHTBLUE," If you think this has been an error, contact a lead administrator.");
            SendClientMessage(strval(tmp),COLOR_LIGHTBLUE,"--------------------------------------------");
            return 1;
        }
        else return SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: You are not an admin !");
        if(strval(tmp) == INVALID_PLAYER_ID) ----------------> LINE 606
        {
            return SendClientMessage(playerid,COLOR_RED,"[ERROR]: Invalid ID.");
        }
        return 1;
    }
Reply
#5

Remove "return" from the line above the error.
Reply
#6

Quote:
Originally Posted by iggy1
Посмотреть сообщение
Remove "return" from the line above the error.
Thank you, based on this comment I could fix all my warnings.

Thread closed !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)