Raised This Month: $51 Target: $400
 12% 

Unreachable code!! HELP!!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 09-23-2017 , 04:36   Unreachable code!! HELP!!
Reply With Quote #1

PHP Code:
public give_nade(idlevelcid)
{
    
//Check access
    
if (!cmd_access(idlevelcid3))
        return 
PLUGIN_HANDLED
        
    
//Check if Award Grenades is enabled
    
if(!get_pcvar_num(award_nades))
        return 
PLUGIN_HANDLED
        
    
//Check arguments
    
new arg1[32], arg2[21], arg3[21]
    
read_argv(1arg131)
    
read_argv(2arg220)
    
read_argv(3arg320)
    
    
//Check player names
    
new name[32], player
    player 
cmd_target(idname3)
    if(!
player)
        return 
PLUGIN_HANDLED
    
    
//Give Grenades
    
new ammo
    
new admin_name[32]
    
get_user_name(idadmin_name31)
    if(
equal(arg2"he")) {
        
ammo cs_get_user_bpammo(player CSW_HEGRENADE)
        if(
ammo get_pcvar_num(he_max)) {
            if(
ammo == 0) {
                
give_item(player"weapon_hegrenade")
                
give_grenade(playerCSW_HEGRENADEstr_to_num(arg3) - 1)
            }
            else
                
give_grenade(playerCSW_HEGRENADEstr_to_num(arg3))
            
        }
        
client_print(playerprint_chat"[RGC] ADMIN:'%s' gave you '%d' HE Grenades."admin_namestr_to_num(arg3))
        
console_print(id"[RGC] You gave '%s' '%d' HE Grenades."namestr_to_num(arg3))
        return 
PLUGIN_HANDLED
    
}
    else if(
equal(arg2"fb")) {
        
ammo cs_get_user_bpammo(player CSW_FLASHBANG)
        if(
ammo get_pcvar_num(fb_max)) {
            if(
ammo == 0) {
                
give_item(player"weapon_flashbang")
                
give_grenade(playerCSW_FLASHBANGstr_to_num(arg3) - 1)
            }
            else
                
give_grenade(playerCSW_FLASHBANGstr_to_num(arg3))
        }
        
client_print(playerprint_chat"[RGC] ADMIN:'%s' gave you '%d' Flash Bangs."admin_namestr_to_num(arg3))
        
console_print(id"[RGC] You gave '%s' '%d' Flash Bangs."namestr_to_num(arg3))
        return 
PLUGIN_HANDLED
    
}
    else if(
equal(arg2"sg")) {
        
ammo cs_get_user_bpammo(player CSW_SMOKEGRENADE)
        if(
ammo get_pcvar_num(sg_max)) {
            if(
ammo == 0) {
                
give_item(player"weapon_smokegrenade")
                
give_grenade(playerCSW_SMOKEGRENADEstr_to_num(arg3) - 1)
            }
            else
                
give_grenade(playerCSW_SMOKEGRENADEstr_to_num(arg3))
        }
        
client_print(playerprint_chat"[RGC] ADMIN:'%s' gave you '%d' Smoke Grenades."admin_namestr_to_num(arg3))
        
console_print(id"[RGC] You gave '%s' '%d' Smoke Grenades."namestr_to_num(arg3))
        return 
PLUGIN_HANDLED
    
}
    else{
        
ammo cs_get_user_bpammo(player CSW_HEGRENADE)
        if(
ammo == 0) {
            
give_item(player"weapon_hegrenade")
            
give_grenade(playerCSW_HEGRENADEget_pcvar_num(he_max) - ammo 1)
        }
        else
            
give_grenade(playerCSW_HEGRENADEget_pcvar_num(he_max) - ammo)
        
ammo cs_get_user_bpammo(player CSW_FLASHBANG)
        if(
ammo == 0) {
            
give_item(player"weapon_flashbang")
            
give_grenade(playerCSW_FLASHBANGget_pcvar_num(fb_max) - ammo 1)
        }
        else
            
give_grenade(playerCSW_FLASHBANGget_pcvar_num(fb_max) - ammo)
        
ammo cs_get_user_bpammo(player CSW_SMOKEGRENADE)
        if(
ammo == 0) {
            
give_item(player"weapon_smokegrenade")
            
give_grenade(playerCSW_SMOKEGRENADEget_pcvar_num(sg_max) - ammo 1)
        }
        else
            
give_grenade(playerCSW_SMOKEGRENADEget_pcvar_num(sg_max) - ammo)
        
client_print(playerprint_chat"[RGC] ADMIN:'%s' gave you ALL Grenades."admin_name)
        
console_print(id"[RGC] You gave '%s' ALL Grenades."name)
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_HANDLED


It shows 1 warning while compiling.
i.e. Unreachable code on line 449

Can anyone help?
__________________
CrAzY MaN is offline
TheSpaniard
Senior Member
Join Date: Jul 2017
Location: Hell
Old 09-23-2017 , 04:43   Re: Unreachable code!! HELP!!
Reply With Quote #2

can you tell me which line is line 449 or highlight it atleast
__________________
And I Am Back.
TheSpaniard is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 09-23-2017 , 06:52   Re: Unreachable code!! HELP!!
Reply With Quote #3

If you have the "if - [else if] - else" construct and in every branch you return from the function then whatever comes after the "else" block will never get executed.
That means that the last "return PLUGIN_HANDLED" in your function will never get executed and is therefore unreachable code.

Last edited by klippy; 09-23-2017 at 06:52.
klippy is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 03:04.


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