warning 225: unreachable code
#1

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

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

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

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;
Reply
#5

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.
Reply
#6

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


Forum Jump:


Users browsing this thread: 1 Guest(s)