SA-MP Forums Archive
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: Unreachable code (/showthread.php?tid=249241)



[SOLVED]Unreachable code - sMog. - 17.04.2011

Hello i have problem ....

PHP код:
stock buycarscore(playerid){
    if((
PlayerInfo[playerid][vowner] == 0) && (GetPlayerScore(playerid) > 100)){
        
buycar(playerid);
        return 
1;
    }else return 
SendClientMessage(playeridCOLOR_BRIGHTRED"You score must be 100+ to buy vehicle!");    
    if((
PlayerInfo[playerid][vowner] == 1) && (GetPlayerScore(playerid) < 300)){
        
buycar(playerid);
        return 
1;
    }else return 
SendClientMessage(playeridCOLOR_BRIGHTRED"You score must be 100+ to buy vehicle!"); 
it coninues...

PHP код:
smog.pwn(19375) : warning 225unreachable code
smog
.pwn(19380) : warning 225unreachable code
smog
.pwn(19385) : warning 225unreachable code
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase 



Re: Unreachable code - Andy6999 - 17.04.2011

Hi your problem is that you are either returning one thing or another with your if/else statement, easy fix.

basically you have to return nothing if you are going to continue checking things with if/else statements
in the else part

pawn Код:
stock buycarscore(playerid){
if((PlayerInfo[playerid][vowner] == 0) && (GetPlayerScore(playerid) > 100)){
    buycar(playerid);
    return 1;
}else /*return*/SendClientMessage(playerid, COLOR_BRIGHTRED, "You score must be 100+ to buy vehicle!");    

if((PlayerInfo[playerid][vowner] == 1) && (GetPlayerScore(playerid) < 300)){
    buycar(playerid);
    return 1;
}else /*return*/SendClientMessage(playerid, COLOR_BRIGHTRED, "You score must be 100+ to buy vehicle!");

//commented out the mistakes you did.



Re: Unreachable code - sMog. - 17.04.2011

thanks it cobiled.

but it wont work ...