Raised This Month: $ Target: $400
 0% 

Duplicate Case Error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RandomUser
Junior Member
Join Date: Jun 2011
Old 02-18-2012 , 11:17   Duplicate Case Error
Reply With Quote #1

I'm getting error 040: duplicate "case" label (value 2) for LR_RAMBO, LR_DUDE, and LR_CRAZY. I know what duplicate case means, I just can't figure out how I'm duplicating a case. And if I'm not, then do I need to see how something is defined to fix it? I'd appreciate any feedback. Thanks.

PHP Code:
enum
{
    
LR_NONE = -1,
    
LR_KNIFE,
    
LR_S4S,
    
LR_NADE,
    
LR_RACE,
    
LR_SPRAY,
    
LR_GUNTOSS,
    
LR_NADETOSS,
    
LR_SCOUT,
    
LR_SHOTGUN,
    
LR_SHOWDOWN,
    
LR_GLOBAL_WAR,
    
LR_CUSTOM,
    
    
MAX_GAMES
}

enum
{
    
LR_NONE = -1,
    
LR_SPECIAL,
    
LR_FREE,
    
LR_RAMBO,
    
LR_DUDE,
    
LR_CRAZY,
    
LR_HIDDEN,
    
    
MAX_REBELS
}

public 
Ham_WeaponTouch_PreiEntityid )
{
    if( !
is_user_aliveid ) )
        return 
HAM_IGNORED;
    
    new 
CsTeams:team cs_get_user_teamid );
    
    switch( 
g_iCurrentGame )
    {
        case 
LR_KNIFELR_S4SLR_NADELR_RACELR_SPRAYLR_NADETOSSLR_SCOUTLR_SHOTGUNLR_SHOWDOWNLR_GLOBAL_WARLR_CUSTOMLR_HIDDEN:
        {
            return 
HAM_SUPERCEDE;
        }
        
        case 
LR_RAMBOLR_DUDELR_CRAZY:
        {
            if( 
team == CS_TEAM_T )
                return 
HAM_SUPERCEDE;
        }
    }
    return 
HAM_IGNORED;


Last edited by RandomUser; 02-18-2012 at 11:22.
RandomUser is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 02-18-2012 , 11:49   Re: Duplicate Case Error
Reply With Quote #2

You have LR_NONE at the start of both the enumerations.

Edit:
Instead of that you could make LR_NONE a const set to -1 & start the enums from 0.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.

Last edited by drekes; 02-18-2012 at 11:50.
drekes is offline
Send a message via MSN to drekes
RandomUser
Junior Member
Join Date: Jun 2011
Old 02-18-2012 , 12:08   Re: Duplicate Case Error
Reply With Quote #3

Well, before i only had LR_NONE = -1, for the first enum, and I was still getting the same error. Also, in the code I have:

PHP Code:
new g_iCurrentGame LR_NONE
It was like this before:

PHP Code:
enum
{
    
LR_NONE = -1,
    
LR_KNIFE,
    
LR_S4S,
    
LR_NADE,
    
LR_RACE,
    
LR_SPRAY,
    
LR_GUNTOSS,
    
LR_NADETOSS,
    
LR_SCOUT,
    
LR_SHOTGUN,
    
LR_SHOWDOWN,
    
LR_GLOBAL_WAR,
    
LR_CUSTOM,
    
    
MAX_GAMES
}

enum
{
    
LR_SPECIAL,
    
LR_FREE,
    
LR_RAMBO,
    
LR_DUDE,
    
LR_CRAZY,
    
LR_HIDDEN,
    
    
MAX_REBELS
}

public 
Ham_WeaponTouch_PreiEntityid )
{
    if( !
is_user_aliveid ) )
        return 
HAM_IGNORED;
    
    new 
CsTeams:team cs_get_user_teamid );
    
    switch( 
g_iCurrentGame )
    {
        case 
LR_KNIFELR_S4SLR_NADELR_RACELR_SPRAYLR_NADETOSSLR_SCOUTLR_SHOTGUNLR_SHOWDOWNLR_GLOBAL_WARLR_CUSTOMLR_HIDDEN:
        {
            return 
HAM_SUPERCEDE;
        }
        
        case 
LR_RAMBOLR_DUDELR_CRAZY:
        {
            if( 
team == CS_TEAM_T )
                return 
HAM_SUPERCEDE;
        }
    }
    return 
HAM_IGNORED;

RandomUser is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-18-2012 , 13:56   Re: Duplicate Case Error
Reply With Quote #4

When you use two enum, several of the variables in each enum have the exact same value. Put them all in one enum if you want to use them all in the same switch statement.

I.e. LR_NADE and LR_RAMBO have the same value.
__________________

Last edited by fysiks; 02-18-2012 at 13:57.
fysiks is offline
RandomUser
Junior Member
Join Date: Jun 2011
Old 02-18-2012 , 17:41   Re: Duplicate Case Error
Reply With Quote #5

Alright. Thanks a lot.
RandomUser 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 19:23.


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