AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   "structs" and enums... (https://forums.alliedmods.net/showthread.php?t=27760)

Zenith77 04-28-2006 15:58

"structs" and enums...
 
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

Greenberet 04-28-2006 16:04

Code:
 enum PLFPS {       pfFPS[FPSRating] };

Zenith77 04-28-2006 16:15

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!

Greenberet 04-28-2006 16:21

Code:
enum PLFPS {       pfFPS };   plfps[id][pfFPS] = frLow; // Correct!

Zenith77 04-28-2006 16:26

It'll give me a tag mismatch, since I am using a defined enum type with an element thats not set to use it.

Greenberet 04-28-2006 16:41

then use this cast
Code:
_:

Zenith77 04-28-2006 16:45

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


Like this right?

Code:
plfps[id][pfFPS] = _:frHigh

Twilight Suzuka 04-28-2006 21:18

Oh god, just use different arrays!


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

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