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



warning 225: unreachable code Problem - RoX123 - 10.09.2017

Hello to all, i have problem with warning 225, i tryed to fix it with remove returns but it isnt works, thanks to all in advance
PHP код:
        if( newkeys == KEY_SECONDARY_ATTACK //55589
        
{
        if( 
IsPlayerInRangeOfPointplayerid3.01480.9410,-1771.8586,18.7958 ) )
        {
        
SetPlayerPosplayerid386.2978,173.8582,1008.3828 ); 
        
SetPlayerInteriorplayerid15 );
        
GameTextForPlayerplayerid"Welcome to city hall"3000); 
        return 
1;
  }
}
        if( 
newkeys == KEY_SECONDARY_ATTACK 
        {
        if( 
IsPlayerInRangeOfPointplayerid3.0386.2978,173.8582,1008.3828 ) ) 
        
SetPlayerPosplayerid1480.9410,-1771.8586,18.7958 ); 
        
SetPlayerInteriorplayerid0); 
        
GameTextForPlayerplayerid"Goodbye"3000);
        return 
1;
      }
        }
    }
    }
  return 
1;




Re: warning 225: unreachable code Problem - Eoussama - 10.09.2017

That was painful to look at, please learn to write readable code.
PHP код:
if( newkeys == KEY_SECONDARY_ATTACK //55589 

    if( 
IsPlayerInRangeOfPointplayerid3.01480.9410,-1771.8586,18.7958 ) )
    { 
        
SetPlayerPosplayerid386.2978,173.8582,1008.3828 );  
        
SetPlayerInteriorplayerid15 ); 
        
GameTextForPlayerplayerid"Welcome to city hall"3000);  
        
        return 
1
    } 

if( 
newkeys == KEY_SECONDARY_ATTACK )  

    if( 
IsPlayerInRangeOfPointplayerid3.0386.2978,173.8582,1008.3828 ) )
    {
        
SetPlayerPosplayerid1480.9410,-1771.8586,18.7958 );  
        
SetPlayerInteriorplayerid0);  
        
GameTextForPlayerplayerid"Goodbye"3000); 
        
        return 
1
    } 

return 
1
Make sure to check up this https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
It contains useful information on how to properly detect Keys, scroll down, you'll find read macros for that.


Re: warning 225: unreachable code Problem - RoX123 - 10.09.2017

Quote:
Originally Posted by Eoussama
Посмотреть сообщение
That was painful to look at, please learn to write readable code.
PHP код:
if( newkeys == KEY_SECONDARY_ATTACK //55589 

    if( 
IsPlayerInRangeOfPointplayerid3.01480.9410,-1771.8586,18.7958 ) )
    { 
        
SetPlayerPosplayerid386.2978,173.8582,1008.3828 );  
        
SetPlayerInteriorplayerid15 ); 
        
GameTextForPlayerplayerid"Welcome to city hall"3000);  
        
        return 
1
    } 

if( 
newkeys == KEY_SECONDARY_ATTACK )  

    if( 
IsPlayerInRangeOfPointplayerid3.0386.2978,173.8582,1008.3828 ) )
    {
        
SetPlayerPosplayerid1480.9410,-1771.8586,18.7958 );  
        
SetPlayerInteriorplayerid0);  
        
GameTextForPlayerplayerid"Goodbye"3000); 
        
        return 
1
    } 

return 
1
Make sure to check up this https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
It contains useful information on how to properly detect Keys, scroll down, you'll find read macros for that.
Yeah i tryed all, now 26 erors
PHP код:
script.pwn(12077) : error 004: function "LoadDrugSystem" is not implemented
  script
.pwn(12078) : error 004: function "LoadMatsSystem" is not implemented
  script
.pwn(12079) : error 004: function "LoadTrunk" is not implemented
  script
.pwn(20268) : error 004: function "ini_GetKey" is not implemented
  script
.pwn(20268) : error 033: array must be indexed (variable "keytmp")
  
script.pwn(20271) : error 004: function "ini_GetValue" is not implemented
  script
.pwn(20271) : error 033: array must be indexed (variable "valtmp")
  
script.pwn(20280) : error 004: function "ini_GetKey" is not implemented
  script
.pwn(20280) : error 033: array must be indexed (variable "key")
  
script.pwn(20281) : error 004: function "ini_GetValue" is not implemented
  script
.pwn(20281) : error 033: array must be indexed (variable "val")
  
script.pwn(20282) : error 004: function "ini_GetValue" is not implemented
  script
.pwn(20282) : error 033: array must be indexed (variable "val")
  
script.pwn(20283) : error 004: function "ini_GetValue" is not implemented
  script
.pwn(20283) : error 033: array must be indexed (variable "val")
  
script.pwn(20284) : error 004: function "ini_GetValue" is not implemented
  script
.pwn(20284) : error 033: array must be indexed (variable "val")
  
script.pwn(20285) : error 004: function "ini_GetValue" is not implemented
  script
.pwn(20285) : error 033: array must be indexed (variable "val")
  
script.pwn(20286) : error 004: function "ini_GetValue" is not implemented
  script
.pwn(20286) : error 033: array must be indexed (variable "val")
  
script.pwn(20287) : error 004: function "ini_GetValue" is not implemented
  script
.pwn(20287) : error 033: array must be indexed (variable "val")
  
script.pwn(20288) : error 004: function "ini_GetValue" is not implemented
  script
.pwn(20288) : error 033: array must be indexed (variable "val")
  
script.pwn(20289) : error 004: function "ini_GetValue" is not implemented
Compilation aborted
.Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
26 Errors




Re: warning 225: unreachable code Problem - silverms - 10.09.2017

it is because of a missing bracket put } under the last return 1; it should work


Re: warning 225: unreachable code Problem - RoX123 - 10.09.2017

Quote:
Originally Posted by silverms
Посмотреть сообщение
it is because of a missing bracket put } under the last return 1; it should work
Again 26 errors


Re: warning 225: unreachable code Problem - AmarPlayer - 10.09.2017

Show me the entire OnPlayerKeyState public.


Re: warning 225: unreachable code Problem - RoX123 - 10.09.2017

PHP код:
                if( newkeys == KEY_SECONDARY_ATTACK //55589
            
{
            if( 
IsPlayerInRangeOfPointplayerid3.01480.9410,-1771.8586,18.7958 ) )
            {
            
SetPlayerPosplayerid386.2978,173.8582,1008.3828 );
            
SetPlayerInteriorplayerid15 );
            
GameTextForPlayerplayerid"Welcome to city hall"3000);
      }
    }
            if( 
newkeys == KEY_SECONDARY_ATTACK )
            {
            if( 
IsPlayerInRangeOfPointplayerid3.0386.2978,173.8582,1008.3828 ) )
            
SetPlayerPosplayerid1480.9410,-1771.8586,18.7958 );
            
SetPlayerInteriorplayerid0);
            
GameTextForPlayerplayerid"Goodbye"3000);
            return 
1;
          }
        }
  return 
1;

Its OK nov, i fixed warnings, but when i come to 386.2978,173.8582,1008.3828 cordinates and press enter or F nothing happen, thanks to all in advance


Re: warning 225: unreachable code Problem - TakeiT - 10.09.2017

Your original problem is that you have return 1; at the end of the code when every "if" statement ends with return 1;

So all you ahve to do is remove the last return 1; and the w arning will go away. The way you've done it above is wrong, you've removed the wrong return.

You also need to have {} after an if statement if you have more than one function. IE:

Код:
if( newkeys == KEY_SECONDARY_ATTACK ) 
            { 
            if( IsPlayerInRangeOfPoint( playerid, 3.0, 386.2978,173.8582,1008.3828 ) ) 
            SetPlayerPos( playerid, 1480.9410,-1771.8586,18.7958 ); 
            SetPlayerInterior( playerid, 0); 
            GameTextForPlayer( playerid, "Goodbye", 3000, 1 ); 
            return 1; 
          }
to
Код:
if( newkeys == KEY_SECONDARY_ATTACK ) 
            { 
                if( IsPlayerInRangeOfPoint( playerid, 3.0, 386.2978,173.8582,1008.3828 ) ) 
                {
                    SetPlayerPos( playerid, 1480.9410,-1771.8586,18.7958 ); 
                    SetPlayerInterior( playerid, 0); 
                    GameTextForPlayer( playerid, "Goodbye", 3000, 1 );
                } 
                return 1; 
          }



Re: warning 225: unreachable code Problem - RoX123 - 10.09.2017

Quote:
Originally Posted by TakeiT
Посмотреть сообщение
Your original problem is that you have return 1; at the end of the code when every "if" statement ends with return 1;

So all you ahve to do is remove the last return 1; and the w arning will go away. The way you've done it above is wrong, you've removed the wrong return.

You also need to have {} after an if statement if you have more than one function. IE:

Код:
if( newkeys == KEY_SECONDARY_ATTACK ) 
            { 
            if( IsPlayerInRangeOfPoint( playerid, 3.0, 386.2978,173.8582,1008.3828 ) ) 
            SetPlayerPos( playerid, 1480.9410,-1771.8586,18.7958 ); 
            SetPlayerInterior( playerid, 0); 
            GameTextForPlayer( playerid, "Goodbye", 3000, 1 ); 
            return 1; 
          }
to
Код:
if( newkeys == KEY_SECONDARY_ATTACK ) 
            { 
                if( IsPlayerInRangeOfPoint( playerid, 3.0, 386.2978,173.8582,1008.3828 ) ) 
                {
                    SetPlayerPos( playerid, 1480.9410,-1771.8586,18.7958 ); 
                    SetPlayerInterior( playerid, 0); 
                    GameTextForPlayer( playerid, "Goodbye", 3000, 1 );
                } 
                return 1; 
          }
With this code i have 26 errors
PHP код:
if( newkeys == KEY_SECONDARY_ATTACK //55589
            
{
            if( 
IsPlayerInRangeOfPointplayerid3.01480.9410,-1771.8586,18.7958 ) )
            {
            
SetPlayerPosplayerid386.2978,173.8582,1008.3828 );
            
SetPlayerInteriorplayerid15 );
            
GameTextForPlayerplayerid"Welcome to city hall"3000);
      }
    }
if( 
newkeys == KEY_SECONDARY_ATTACK )
            {
                if( 
IsPlayerInRangeOfPointplayerid3.0386.2978,173.8582,1008.3828 ) )
                {
                    
SetPlayerPosplayerid1480.9410,-1771.8586,18.7958 );
                    
SetPlayerInteriorplayerid0);
                    
GameTextForPlayerplayerid"Goodbye"3000);
                }
                return 
1;
          } 
And with this no any errors but when i come to cordinates pickup dont work, i dont go to any interior
PHP код:
                if( newkeys == KEY_SECONDARY_ATTACK //55589
            
{
            if( 
IsPlayerInRangeOfPointplayerid3.01480.9410,-1771.8586,18.7958 ) )
            {
            
SetPlayerPosplayerid386.2978,173.8582,1008.3828 );
            
SetPlayerInteriorplayerid15 );
            
GameTextForPlayerplayerid"Welcome to city hall"3000);
      }
    }
            if( 
newkeys == KEY_SECONDARY_ATTACK )
            {
            if( 
IsPlayerInRangeOfPointplayerid3.0386.2978,173.8582,1008.3828 ) )
            
SetPlayerPosplayerid1480.9410,-1771.8586,18.7958 );
            
SetPlayerInteriorplayerid0);
            
GameTextForPlayerplayerid"Goodbye"3000);
            return 
1;
          }
        }
  return 
1;




Re: warning 225: unreachable code Problem - JasonRiggs - 11.09.2017

Change your code to this

PHP код:
                if( newkeys == KEY_SECONDARY_ATTACK //55589
            
{
            if( 
IsPlayerInRangeOfPointplayerid3.01480.9410,-1771.8586,18.7958 ) )
            {
            
SetPlayerPosplayerid386.2978,173.8582,1008.3828 );
            
SetPlayerInteriorplayerid15 );
            
GameTextForPlayerplayerid"Welcome to city hall"3000);
            return 
1;
      }
    }
            if( 
newkeys == KEY_SECONDARY_ATTACK )
            {
            if( 
IsPlayerInRangeOfPointplayerid3.0386.2978,173.8582,1008.3828 ) )
            
SetPlayerPosplayerid1480.9410,-1771.8586,18.7958 );
            
SetPlayerInteriorplayerid0);
            
GameTextForPlayerplayerid"Goodbye"3000);
            return 
1;
          }
        }


  return 
1;