SA-MP Forums Archive
Unrachable 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: Unrachable Code (/showthread.php?tid=431283)



Unrachable Code - daniel2499 - 17.04.2013

pawn Код:
{
    new pName[MAX_PLAYER_NAME];
    new String[128];
    new Anti;
    new R;
    while(strlen(text[Anti]))
    {
      if('0' <= text[Anti] <= '9')
      {
        new Anti2 = Anti+1;
        new P;
        while(P == 0)
        {
          if('0' <= text[Anti2] <= '9' && strlen(text[Anti2])) Anti2 ++;
          else
          {
            strmid(String[R] , text , Anti , Anti2 , 255);
            if(strval(String[R]) < 255) R ++;
            Anti = Anti2;
            P = 1;
          }
        }
      }
      Anti ++;
    }
    if(R >= 4)
    {
      for(new z = 0; z < R; z++)
      {
        new AntiServer;
        while((AntiServer = strfind(text,String[z] , true)) !=-1)
        for(new i = AntiServer,j = AntiServer+strlen(String[z]); i < j; i ++) text[i] = '*';
        if(Warnings[playerid] == 3)
        {
          GetPlayerName(playerid,pName,sizeof(pName));
          format(String,sizeof(String),"\"%s\" {FFFF00}Has Kicked From The Server ({FF0000C}Reason: {FFFF00}Server Publishing)",pName);
          SendClientMessageToAll(0xFF0000C8,String);
          Warnings[playerid] = 0;
          Kick(playerid);
        }
        else
        {
          Warnings[playerid] ++;
          format(String,sizeof(String),"Do Not Advertise Other Servers In Our Server {FF9900}[%d/3]",Warnings[playerid]);
          SendClientMessage(playerid,0xFF0000C8,String);
          }
        return 0;
}
}
    return 1;
}
Error :
pawn Код:
warning 225: unreachable code



Re: Unrachable Code - TomatoRage - 17.04.2013

which line ??


Re: Unrachable Code - daniel2499 - 17.04.2013

pawn Код:
format(String,sizeof(String),"Do Not Advertise Other Servers On Our Server {FF9900}[%d/3]",Warnings[playerid]);
          SendClientMessage(playerid,0xFF0000C8,String);
        }
        return 0;
      }
    }
    return 1;
}



Re: Unrachable Code - Babul - 17.04.2013

what is the
pawn Код:
return 0;
supposed to break?
comment it out, and see what happens.


Re: Unrachable Code - daniel2499 - 17.04.2013

Quote:
Originally Posted by Babul
Посмотреть сообщение
what is the
pawn Код:
return 0;
supposed to break?
comment it out, and see what happens.
same error ..


Re: Unrachable Code - Babul - 17.04.2013

its close to impossible that the compiler complains unreachable code after
pawn Код:
Warnings[playerid] ++;
...not being able to reach a simple format() after that.
maybe post the whole command, and add a //comment for the line?
edit: nvm. i still come to the conclusion that the return 0; breaks the for loop, therefore the return 1; cannot be reached.
edit2: and iam wrong? i added
pawn Код:
new text[256];
new Warnings[MAX_PLAYERS];
CMD:test2(playerid,params[])
{
    new pName[MAX_PLAYER_NAME];
    new String[128];
    new Anti;
//...
..to be able to compile the command. it doesnt show any warning here o.O

edit3: erm. i need to ask a stupid question: is it LINE 225 you posted? read the whole report, it may show a different line number before the warning. like
(659): warning 225: unreachable code

btw, do this:
pawn Код:
return 1;
return 0;
then you force another warning about the return 0; not getting executed. try it


Re: Unrachable Code - daniel2499 - 17.04.2013

Quote:
Originally Posted by Babul
Посмотреть сообщение
its close to impossible that the compiler complains unreachable code after
pawn Код:
Warnings[playerid] ++;
...not being able to reach a simple format() after that.
maybe post the whole command, and add a //comment for the line?
edit: nvm. i still come to the conclusion that the return 0; breaks the for loop, therefore the return 1; cannot be reached.
edit2: and iam wrong? i added
pawn Код:
new text[256];
new Warnings[MAX_PLAYERS];
CMD:test2(playerid,params[])
{
    new pName[MAX_PLAYER_NAME];
    new String[128];
    new Anti;
//...
..to be able to compile the command. it doesnt show any warning here o.O

edit3: erm. i need to ask a stupid question: is it LINE 225 you posted? read the whole report, it may show a different line number before the warning. like
(659): warning 225: unreachable code

btw, do this:
pawn Код:
return 1;
return 0;
then you force another warning about the return 0; not getting executed. try it
full code please ..


Re: Unrachable Code - daniel2499 - 18.04.2013

UP ..


Re: Unrachable Code - zT KiNgKoNg - 18.04.2013

Don't bump your posts please, Nobody will reply to them with an answer.