Raised This Month: $ Target: $400
 0% 

"structs" and enums...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Zenith77
Veteran Member
Join Date: Aug 2005
Old 04-28-2006 , 15:58   "structs" and enums...
Reply With Quote #1

In the plugin I am creating, I'm using enums to simulate a stuct.
What I want to know is how can I put an enum inside an enum without the compiler crashing, if its even possible.

Example: Lets say you want have a "struct" that stores a player's FPS, and rate it "high", "medium", "low".

Code:
enum FPSRating {        frHigh,        frMedium,        frLow }; enum PLFPS {       pfFPS };

and then I want to make pfFPS "rateable" by doing this...

Code:
enum PLFPS {       FPSRating pfFPS };

How can I do this without the compiler crashing?

--Zenith
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Greenberet
AMX Mod X Beta Tester
Join Date: Apr 2004
Location: Vienna
Old 04-28-2006 , 16:04  
Reply With Quote #2

Code:
 enum PLFPS {       pfFPS[FPSRating] };
Greenberet is offline
Send a message via ICQ to Greenberet Send a message via MSN to Greenberet
Zenith77
Veteran Member
Join Date: Aug 2005
Old 04-28-2006 , 16:15  
Reply With Quote #3

No, thats not what I want to do. What you did would allow me to access each element of the enum with the array.

I want pfFPS to have to be set to either frHigh, frMedium, frLow.

Code:
FPSRating pfFPS; ... new plfps[33][PLFPS]; ... plfps[id][pfFPS] = frLow; // Correct! plfps[id][pfFPS] = 300 // Wrong!
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Greenberet
AMX Mod X Beta Tester
Join Date: Apr 2004
Location: Vienna
Old 04-28-2006 , 16:21  
Reply With Quote #4

Code:
enum PLFPS {       pfFPS };   plfps[id][pfFPS] = frLow; // Correct!
Greenberet is offline
Send a message via ICQ to Greenberet Send a message via MSN to Greenberet
Zenith77
Veteran Member
Join Date: Aug 2005
Old 04-28-2006 , 16:26  
Reply With Quote #5

It'll give me a tag mismatch, since I am using a defined enum type with an element thats not set to use it.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Greenberet
AMX Mod X Beta Tester
Join Date: Apr 2004
Location: Vienna
Old 04-28-2006 , 16:41  
Reply With Quote #6

then use this cast
Code:
_:
Greenberet is offline
Send a message via ICQ to Greenberet Send a message via MSN to Greenberet
Zenith77
Veteran Member
Join Date: Aug 2005
Old 04-28-2006 , 16:45  
Reply With Quote #7

I tired to :'(, still gave me tag mismatch...


Like this right?

Code:
plfps[id][pfFPS] = _:frHigh
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 04-28-2006 , 21:18  
Reply With Quote #8

Oh god, just use different arrays!
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
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 05:14.


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