Unreachable code
#1

Код:
(491) : warning 225: unreachable code
PHP код:
if(dialogid == VIPMENU//LINE 419
    
{
        if(
response
        {
            
            if(
listitem == 0// Health
            
{
               if(
PlayerData[playerid][Level] >= 1)
                    {
                    
SetPlayerHealth(playerid,100);
                 }
            }
            if(
listitem == 1// Armour
            
{
               if(
PlayerData[playerid][Level] >= 1)
                    {
                   
SetPlayerArmour(playerid,100);
                 }
            }
            if(
listitem == 2// Weaponry
            
{
               if(
PlayerData[playerid][Level] >= 1)
              {
                
GivePlayerWeapon(playerid4,1);
                
GivePlayerWeapon(playerid24,8000);
                
GivePlayerWeapon(playerid26,8000);
                
GivePlayerWeapon(playerid32,8000);
                
GivePlayerWeapon(playerid34,8000); 
              }
            }
            if(
listitem == 3// Nos
            
{
               if(
PlayerData[playerid][Level] >= 1)
               {
                
AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
               }
            }
            if(
listitem == 1// Vehicle HP
            
{
               if(
PlayerData[playerid][Level] >= 1)
                    {
                   new 
vehicleid GetPlayerVehicleID(playerid);
                   
SetVehicleHealth(vehicleid1000.0);
                 }
            }
        }
        return 
1// We handled a dialog, so return 1. Just like OnPlayerCommandText.
    
}
    return 
1;

Any idea?Thanks in advance!
Reply
#2

There is a missing bracket above the 419th line.
Reply
#3

Where at?I dont see something wrong here:S
Reply
#4

Show us the the rest of OnDialogResponse
Reply
#5

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid == ConfigDialog)
    {
        case 
1:
        {
               switch(
listitem)
            {
                case 
0:
                {
                    if(
response)
                    {
                        
ShowPlayerDialog(playerid,MaxLevelDialog,DIALOG_STYLE_INPUT,"Change max. VIP level:","Insert your new max. VIP level!","Change","Back");
                    }
                    else
                    {
                        return 
0;
                    }
                }
                case 
1:
                {
                    if(
response)
                    {
                        
ShowPlayerDialog(playerid,MoneyForJoin,DIALOG_STYLE_INPUT,"Change money for join:","Insert your new ammount of money which\nwill VIP player receive when they connect!","Change","Back");
                    }
                    else
                    {
                        return 
0;
                    }
                }
                case 
2:
                {
                    if(
response)
                    {
                        
ShowPlayerDialog(playerid,ScoreForJoin,DIALOG_STYLE_INPUT,"Change score for join:","Insert your new ammount of score which\nwill VIP player receive when they connect!","Change","Back");
                    }
                    else
                    {
                        return 
0;
                    }
                }
                case 
3:
                {
                    if(
response)
                    {
                        
SendClientMessage(playerid,COLOR_RED,"{FF0000}ERROR: {FFFFFF}You cant change ammount of total VIP accounts!");
                        new 
cfg[500];
                        
format(cfg,sizeof(cfg),"{FFFFFF}Max VIP Level:\t\t{FFFF00}%d\n{FFFFFF}Money for join:\t\t{FFFF00}%d$\n{FFFFFF}Score for join:\t\t{FFFF00}%d\n{FFFFFF}Total accounts:\t\t{FFFF00}%d",MaxLevel,MoneyAdd,ScoreAdd,TotalAccounts);
                        
ShowPlayerDialog(playerid,ConfigDialog,DIALOG_STYLE_LIST,"{00FF40}VIP System Configuration:",cfg,"Select","Close");
                    }
                    else
                    {
                        return 
0;
                    }
                }
            }
        }
    }
    switch(
dialogid == MaxLevelDialog)
    {
        case 
1:
        {
            if(
response)
            {
                new 
MAX_LVL[50];
                new 
lvl strval(inputtext);
                
format(MAX_LVL,sizeof(MAX_LVL),"VIP/Files/Configuration.txt");
                if(
dini_Exists(MAX_LVL))
                {
                    
dini_IntSet(MAX_LVL,"MaxVipLevel",lvl);
                }
                new 
cfg[500];
                
format(cfg,sizeof(cfg),"{FFFFFF}Max VIP Level:\t\t{FFFF00}%d\n{FFFFFF}Money for join:\t\t{FFFF00}%d$\n{FFFFFF}Score for join:\t\t{FFFF00}%d\n{FFFFFF}Total accounts:\t\t{FFFF00}%d",MaxLevel,MoneyAdd,ScoreAdd,TotalAccounts);
                
ShowPlayerDialog(playerid,ConfigDialog,DIALOG_STYLE_LIST,"{00FF40}VIP System Configuration:",cfg,"Select","Close");
            }
            else if(!
response)
            {
                new 
cfg[500];
                
format(cfg,sizeof(cfg),"{FFFFFF}Max VIP Level:\t\t{FFFF00}%d\n{FFFFFF}Money for join:\t\t{FFFF00}%d$\n{FFFFFF}Score for join:\t\t{FFFF00}%d\n{FFFFFF}Total accounts:\t\t{FFFF00}%d",MaxLevel,MoneyAdd,ScoreAdd,TotalAccounts);
                
ShowPlayerDialog(playerid,ConfigDialog,DIALOG_STYLE_LIST,"{00FF40}VIP System Configuration:",cfg,"Select","Close");
            }
        }
     }
     switch(
dialogid == MoneyForJoin)
    {
        case 
1:
        {
            if(
response)
            {
                new 
MONEY_JOIN[50];
                new 
money strval(inputtext);
                
format(MONEY_JOIN,sizeof(MONEY_JOIN),"VIP/Files/Configuration.txt");
                if(
dini_Exists(MONEY_JOIN))
                {
                    
dini_IntSet(MONEY_JOIN,"MoneyForJoin",money);
                }
                new 
cfg[500];
                
format(cfg,sizeof(cfg),"{FFFFFF}Max VIP Level:\t\t{FFFF00}%d\n{FFFFFF}Money for join:\t\t{FFFF00}%d$\n{FFFFFF}Score for join:\t\t{FFFF00}%d\n{FFFFFF}Total accounts:\t\t{FFFF00}%d",MaxLevel,MoneyAdd,ScoreAdd,TotalAccounts);
                
ShowPlayerDialog(playerid,ConfigDialog,DIALOG_STYLE_LIST,"{00FF40}VIP System Configuration:",cfg,"Select","Close");
            }
            else if(!
response)
            {
                new 
cfg[500];
                
format(cfg,sizeof(cfg),"{FFFFFF}Max VIP Level:\t\t{FFFF00}%d\n{FFFFFF}Money for join:\t\t{FFFF00}%d$\n{FFFFFF}Score for join:\t\t{FFFF00}%d\n{FFFFFF}Total accounts:\t\t{FFFF00}%d",MaxLevel,MoneyAdd,ScoreAdd,TotalAccounts);
                
ShowPlayerDialog(playerid,ConfigDialog,DIALOG_STYLE_LIST,"{00FF40}VIP System Configuration:",cfg,"Select","Close");
            }
        }
     }
     switch(
dialogid == ScoreForJoin)
    {
        case 
1:
        {
            if(
response)
            {
                new 
SCORE_JOIN[50];
                new 
score strval(inputtext);
                
format(SCORE_JOIN,sizeof(SCORE_JOIN),"VIP/Files/Configuration.txt");
                if(
dini_Exists(SCORE_JOIN))
                {
                    
dini_IntSet(SCORE_JOIN,"ScoreForJoin",score);
                }
                new 
cfg[500];
                
format(cfg,sizeof(cfg),"{FFFFFF}Max VIP Level:\t\t{FFFF00}%d\n{FFFFFF}Money for join:\t\t{FFFF00}%d$\n{FFFFFF}Score for join:\t\t{FFFF00}%d\n{FFFFFF}Total accounts:\t\t{FFFF00}%d",MaxLevel,MoneyAdd,ScoreAdd,TotalAccounts);
                
ShowPlayerDialog(playerid,ConfigDialog,DIALOG_STYLE_LIST,"{00FF40}VIP System Configuration:",cfg,"Select","Close");
            }
            else if(!
response)
            {
                new 
cfg[500];
                
format(cfg,sizeof(cfg),"{FFFFFF}Max VIP Level:\t\t{FFFF00}%d\n{FFFFFF}Money for join:\t\t{FFFF00}%d$\n{FFFFFF}Score for join:\t\t{FFFF00}%d\n{FFFFFF}Total accounts:\t\t{FFFF00}%d",MaxLevel,MoneyAdd,ScoreAdd,TotalAccounts);
                
ShowPlayerDialog(playerid,ConfigDialog,DIALOG_STYLE_LIST,"{00FF40}VIP System Configuration:",cfg,"Select","Close");
            }
        }
     }
    return 
1;
    
    if(
dialogid == VIPMENU)
    {
        if(
response
        {
            if(
listitem == 0// Health
            
{
               if(
PlayerData[playerid][Level] >= 1)
                    {
                    
SetPlayerHealth(playerid,100);
                 }
            }
            if(
listitem == 1// Armour
            
{
               if(
PlayerData[playerid][Level] >= 1)
                    {
                   
SetPlayerArmour(playerid,100);
                 }
            }
            if(
listitem == 2// Weaponry
            
{
               if(
PlayerData[playerid][Level] >= 1)
              {
                
GivePlayerWeapon(playerid4,1);
                
GivePlayerWeapon(playerid24,8000);
                
GivePlayerWeapon(playerid26,8000);
                
GivePlayerWeapon(playerid32,8000);
                
GivePlayerWeapon(playerid34,8000); 
              }
            }
            if(
listitem == 3// Nos
            
{
               if(
PlayerData[playerid][Level] >= 1)
               {
                
AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
               }
            }
            if(
listitem == 1// Vehicle HP
            
{
               if(
PlayerData[playerid][Level] >= 1)
                    {
                   new 
vehicleid GetPlayerVehicleID(playerid);
                   
SetVehicleHealth(vehicleid1000.0);
                 }
            }
        }
        return 
1// We handled a dialog, so return 1. Just like OnPlayerCommandText.
    
}
    return 
1;

Reply
#6

Remove the "return 1;" line above the error line. A return will end the function/callback, thus making the code underneath unreachable.
Reply
#7

what?
Reply
#8

The error:
Код:
(491) : warning 225: unreachable code
The error line:
pawn Код:
if(dialogid == VIPMENU) //LINE 419
I told you to remove "return 1;" above the error line:
pawn Код:
//line above return 1;  
//error line    if(dialogid == VIPMENU)
//line below    {
I don't see why you didn't get this, but I'll try again: You need to remove the "return 1;" which I specified above, because it's stopping your callback (OnDialogReponse) from continuing, thus making your if-statement unreachable.
Reply
#9

Also, you should return 0 at the end of the callback or else it won't be called in other scripts.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)