Is there any way to access an enum by index? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Is there any way to access an enum by index? (
/showthread.php?tid=268237)
Is there any way to access an enum by index? -
Incubator - 11.07.2011
The lack of the possibility to loop through enums drives me crazy.
Re: Is there any way to access an enum by index? -
Steven82 - 11.07.2011
This....is just..random.
Re: Is there any way to access an enum by index? -
Incubator - 11.07.2011
Eh?
Re: Is there any way to access an enum by index? -
MoroDan - 11.07.2011
Yes. Example:
PHP Code:
enum ENUM_NAME
{
X = 3,
Float:Y = 5.2,
bool:B = false
}
X - ENUM_NAME:0
Y - ENUM_NAME:1
B - ENUM_NAME:2
for(new i = 0; ENUM_NAME:i < ENUM_NAME; i++)
printf("#%d - %d", i, ENUM_NAME:i); // prints the INDEX
Re: Is there any way to access an enum by index? -
Incubator - 11.07.2011
Quote:
Originally Posted by MoroDan
Yes. Example:
PHP Code:
enum ENUM_NAME
{
X = 3,
Float:Y = 5.2,
bool:B = false
}
X - ENUM_NAME:0
Y - ENUM_NAME:1
B - ENUM_NAME:2
for(new i = 0; ENUM_NAME:i < ENUM_NAME; i++)
printf("#%d - %d", i, ENUM_NAME:i); // prints the INDEX
|
Thank you mate.
Re: Is there any way to access an enum by index? -
Incubator - 11.07.2011
Actually it doesn't work.
PickupsList - Dealership:0
will give a warning of "invalid function or declaration".
Re: Is there any way to access an enum by index? -
Incubator - 11.07.2011
I did try, right after the enum:
Code:
enum PickupList
{
Dealership,
Rental
}
PickupList - Dealership:0
PickupList - Rental:1
Quote:
error 010: invalid function or declaration
|
on line "PickupList - Dealership:0"
Re: Is there any way to access an enum by index? -
Vince - 11.07.2011
That's not supposed to be there. That's just documentation. Comment it or remove it if you want.
Re: Is there any way to access an enum by index? -
Incubator - 11.07.2011
Oh, thank you, got it working.