AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   warning 225: unreachable code (https://forums.alliedmods.net/showthread.php?t=132000)

buzzy147 07-10-2010 21:02

warning 225: unreachable code
 
..

Bugsy 07-10-2010 21:11

Re: warning 225: unreachable code
 
Anywhere you see the word 'return' in code, no code after that will be reached because the code exits the function at that line. I highlighted the lines that are unreachable. Of course you can sometimes see return PLUGIN_HANDLED (or w\e) with code after it but it is usually found within some type of conditional which will still allow code after it to be reached.

Code:
        client_print(id, print_chat, "[AMXX] Voce nao esta em uma mapa de surf.")         return PLUGIN_HANDLED         if(cs_get_user_money(id) < 7000)         {             client_print(id, print_chat, "[AMXX] Voce nao tem dinheiro suficiente.")             return PLUGIN_HANDLED             if(cs_get_user_money(id) > 7000)             {                 set_task(0.1,"open_jail",id)                 cs_set_user_money(id, cs_get_user_money(id) - 7000);             }

Example of when it can be ok for code after a return
PHP Code:

FuncBlah()
{
      if ( 
== 10 )
      {
            
//do this stuff
            
return PLUGIN_HANDLED;
      }
    
      
//Do this stuff since a was not equal to 10 and this code was reached
      
*= 55;
      return 
PLUGIN_HANDLED;



buzzy147 07-10-2010 21:41

Re: warning 225: unreachable code
 
..


All times are GMT -4. The time now is 07:05.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.