SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 10/09/2017, 07:58 PM   #1
RoX123
Big Clucker
 
Join Date: Apr 2017
Posts: 83
Reputation: 1
Post warning 225: unreachable code Problem

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 Code:
        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;

RoX123 is offline   Reply With Quote
Old 10/09/2017, 08:01 PM   #2
Eoussama
High-roller
 
Eoussama's Avatar
 
Join Date: Jul 2016
Location: Kingdom of Morocco // Tangier
Posts: 1,071
Reputation: 281
Default Re: warning 225: unreachable code Problem

That was painful to look at, please learn to write readable code.
PHP Code:
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 http://wiki.sa-mp.com/wiki/OnPlayerKeyStateChange
It contains useful information on how to properly detect Keys, scroll down, you'll find read macros for that.
__________________

|===[Web taxi]===|
List of my work
Github
Pastebin

|===[Interesting topics]===|
Semantic Versioning
Eoussama is offline   Reply With Quote
Old 10/09/2017, 08:08 PM   #3
RoX123
Big Clucker
 
Join Date: Apr 2017
Posts: 83
Reputation: 1
Default Re: warning 225: unreachable code Problem

Quote:
Originally Posted by Eoussama View Post
That was painful to look at, please learn to write readable code.
PHP Code:
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 http://wiki.sa-mp.com/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 Code:
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

RoX123 is offline   Reply With Quote
Old 10/09/2017, 08:55 PM   #4
silverms
Huge Clucker
 
Join Date: Sep 2016
Location: USA
Posts: 240
Reputation: 9
Default Re: warning 225: unreachable code Problem

it is because of a missing bracket put } under the last return 1; it should work
__________________
Addons
silverms is offline   Reply With Quote
Old 10/09/2017, 09:04 PM   #5
RoX123
Big Clucker
 
Join Date: Apr 2017
Posts: 83
Reputation: 1
Default Re: warning 225: unreachable code Problem

Quote:
Originally Posted by silverms View Post
it is because of a missing bracket put } under the last return 1; it should work
Again 26 errors
RoX123 is offline   Reply With Quote
Old 10/09/2017, 10:17 PM   #6
AmarPlayer
Little Clucker
 
Join Date: Jul 2017
Location: Bosnia and Herzegovina
Posts: 43
Reputation: 3
Default Re: warning 225: unreachable code Problem

Show me the entire OnPlayerKeyState public.
AmarPlayer is offline   Reply With Quote
Old 10/09/2017, 11:38 PM   #7
RoX123
Big Clucker
 
Join Date: Apr 2017
Posts: 83
Reputation: 1
Default Re: warning 225: unreachable code Problem

PHP Code:
                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
RoX123 is offline   Reply With Quote
Old 10/09/2017, 11:53 PM   #8
TakeiT
Gangsta
 
Join Date: May 2014
Location: Toronto, Canada
Posts: 740
Reputation: 157
Default Re: warning 225: unreachable code Problem

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:

Code:
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
Code:
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; 
          }
TakeiT is offline   Reply With Quote
Old 11/09/2017, 12:07 AM   #9
RoX123
Big Clucker
 
Join Date: Apr 2017
Posts: 83
Reputation: 1
Default Re: warning 225: unreachable code Problem

Quote:
Originally Posted by TakeiT View Post
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:

Code:
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
Code:
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 Code:
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 Code:
                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;

RoX123 is offline   Reply With Quote
Old 11/09/2017, 01:02 AM   #10
JasonRiggs
Gangsta
 
Join Date: Jul 2016
Location: My bedroom.
Posts: 780
Reputation: 47
Default Re: warning 225: unreachable code Problem

Change your code to this

PHP Code:
                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;

__________________
JasonRiggs is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
warning 225: unreachable code Man43 Scripting Help 4 18/04/2017 01:31 PM
warning 225: unreachable code Zeddclarity Scripting Help 2 27/07/2015 01:47 PM
warning 225: unreachable code dafuq Scripting Help 4 04/10/2012 01:45 PM
Warning : Unreachable code. Benzke Scripting Help 2 02/09/2012 06:46 AM
warning 225: unreachable code Torran Scripting Help 6 28/01/2012 05:16 AM


All times are GMT. The time now is 02:37 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.