SA-MP Forums Archive
[Quick question] Unreachable 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Quick question] Unreachable code (/showthread.php?tid=196141)



[Quick question] Unreachable code - admantis - 04.12.2010

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


Re: [Quick question] Unreachable code - Osviux - 04.12.2010

Код:
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; 
        }



Re: [Quick question] Unreachable code - iggy1 - 04.12.2010

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;
    }



Re: [Quick question] Unreachable code - admantis - 04.12.2010

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;
    }



Re: [Quick question] Unreachable code - iggy1 - 04.12.2010

Remove "return" from the line above the error.


Re: [Quick question] Unreachable code - admantis - 04.12.2010

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 !