SA-MP Forums Archive
warning 225: 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)
+--- Thread: warning 225: unreachable code (/showthread.php?tid=611162)



warning 225: unreachable code - AnoTek - 02.07.2016

Код:
	if(success)
	{
		SpamCheck[playerid] = GetTickCount();
	}
	if(!success) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: Unknown command.");
	return 1;
How can i solve this?


Re: warning 225: unreachable code - Golimad - 02.07.2016

if(success)
{
SpamCheck[playerid] = GetTickCount();
return 1;
}
if(!success) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: Unknown command.");


Re: warning 225: unreachable code - DarkSkull - 03.07.2016

Try this:
PHP код:
if(success)
    {
        
SpamCheck[playerid] = GetTickCount();
return 
1;
    }
    else {return 
SendClientMessage(playeridCOLOR_WHITE"{FFFFCC}Error: Unknown command."); } 



Re: warning 225: unreachable code - DTV - 03.07.2016

The reason the warning shows up is because your if statements both end with a return, the code will never reach the "return 1;" at the bottom because of this.

pawn Код:
if(success)
    {
        SpamCheck[playerid] = GetTickCount();
    }
    if(!success)
        {
                SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: Unknown command."); // no need to have "return" in front of this.
        }
    return 1;



Re: warning 225: unreachable code - Nero_3D - 03.07.2016

The given code won't case that warning if you try to compile it
You are probably looking at the wrong code

Also try to lookup the warning in pawn-lang.pdf
Quote:
Originally Posted by pawn-lang.pdf
225 unreachable code: The indicated code will never run, because an instruction before (above) it causes a jump out of the function, out of a loop or elsewhere. Look for return, break, continue and goto instructions above the indicated line. Unreachable code can also be caused by an endless loop above the indicated line.



Re: warning 225: unreachable code - DRIFT_HUNTER - 03.07.2016

Код:
	if(success) SpamCheck[playerid] = GetTickCount();
	else return SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: Unknown command.");