SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 19/03/2013, 11:44 AM   #1
LarzI
High-roller
 
LarzI's Avatar
 
Join Date: Apr 2007
Location: Norway
Posts: 2,628
Reputation: 136
Default Enum tag inside another enum?

Is there any possiblity of using a double-enum tag (I will provide an example below) without getting a tag mismatch error AND without having to put _: to clear it?

It's quite a stupid question as it is asked out of lazyness, but I'm just wondering.

Say you have a code like this:

pawn Code:
enum E_MY_ENUM
{
    E_DATA1,
    E_DATA2
};

enum E_MY_2ND_ENUM
{
    E_MY_ENUM:E2_DATA1,
    E2_DATA2
};

new
    MyVar[ E_MY_2ND_ENUM ]
;

I would then like to use it like this:

pawn Code:
MyVar[ E2_DATA1 ] = E_DATA2;

EDIT: I misspoke. That code above does NOT give me a warning, but if I try to print the data, then I do. I would like to be able to print out the value and use it as an integer, kind of.

Because of lazyness, I would like to not having to do so, but still don't get a tag mismatch warning.

I tried making a macro for it as a last resort (see below), but that crashed my compiler.

pawn Code:
#define MyVar _:MyVar

I also tried another way of doing it, by calling the variable something really... weird, then make a macro called MyVar to "mimic" that variable, but when I then assigned that variable I got another warning saying that the tag was being hidden:

pawn Code:
#define MyVar _:TESTVARIABLEIWILLNEVERUSETHENAMEOF

MyVar[ E2_DATA1 ] = E_DATA1;

Code:
warning 221: label name "_" shadows tag name

Any help would be appreciated!
__________________


NEW: [FS] Simple Cellphones

if( strfind( title, "REP", true ) != -1 )
{________________________________________
Sigh();__________________________
}________________________________________


LarzI is offline   Reply With Quote
Old 19/03/2013, 12:19 PM   #2
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,528
Reputation: 556
Default Re: Enum tag inside another enum?

Print takes only one strong tag - Float. You could try with weak tag: http://wiki.sa-mp.com/wiki/Scripting:tags#Weak_tags
Misiur is offline   Reply With Quote
Old 19/03/2013, 12:22 PM   #3
LarzI
High-roller
 
LarzI's Avatar
 
Join Date: Apr 2007
Location: Norway
Posts: 2,628
Reputation: 136
Default Re: Enum tag inside another enum?

I will try - cheers
__________________


NEW: [FS] Simple Cellphones

if( strfind( title, "REP", true ) != -1 )
{________________________________________
Sigh();__________________________
}________________________________________


LarzI is offline   Reply With Quote
Old 19/03/2013, 12:25 PM   #4
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,528
Reputation: 556
Default Re: Enum tag inside another enum?

pawn Code:
enum e_MY_ENUM
{
    E_DATA1,
    E_DATA2
};

enum E_MY_2ND_ENUM
{
    e_MY_ENUM:E2_DATA1,
    E2_DATA2
};

new
    MyVar[ E_MY_2ND_ENUM ]
;

main() {
    MyVar[ E2_DATA1 ] = E_DATA2;
    printf("We at @%d", MyVar[E2_DATA1]);
}
Misiur is offline   Reply With Quote
Old 19/03/2013, 02:10 PM   #5
LarzI
High-roller
 
LarzI's Avatar
 
Join Date: Apr 2007
Location: Norway
Posts: 2,628
Reputation: 136
Default Re: Enum tag inside another enum?

- ignore -

Cheers.

For anyone wondering why I want this: I just simply find this a bit more systematic than making 89273489234 macros when assigning values

pawn Code:
// instead of doing this:
#define VAL1 (0)
#define VAL2 (1)

new
    MyVar[ MAX_PLAYERS ]
;

MyVar[ playerid ] = VAL1;
__________________


NEW: [FS] Simple Cellphones

if( strfind( title, "REP", true ) != -1 )
{________________________________________
Sigh();__________________________
}________________________________________


LarzI 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
Enum to check another enum? Lz Scripting Help 4 14/12/2012 06:05 PM
[Ajuda] enum Lucas-Fc Português/Portuguese 4 22/11/2012 08:50 PM
[SOLVED] Integer array inside an enum -zriptarusk Help Archive 11 20/03/2009 12:34 AM


All times are GMT. The time now is 07:59 AM.


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