Enum/NormalVar - 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: Enum/NormalVar (
/showthread.php?tid=268744)
Enum/NormalVar -
Roko_foko - 13.07.2011
What's better to use enums or just global variables? What take less memory, or the taken memory is the same in both cases?
Example:
pawn Код:
enum My_Enum
{
var1,
var2,
var3,
}new Info[My_Enum];
or
Re: Enum/NormalVar -
Toreno - 13.07.2011
I don't know what takes less/more memory, but in my opinion, enum is much more easier to work with because all of you variables in one variable which enum controls it. That's what I think, at least.
Re: Enum/NormalVar -
Roko_foko - 13.07.2011
Okay, I used to use normal variables and I am fine with them, but I think I have somewhere read that enums take less memory, what isn't logical unless it is a pointer. So I am asking is it worth to learn about enums since I am satisfied with normal Vars
Re: Enum/NormalVar -
iggy1 - 13.07.2011
Enums are often better to use (than an array) because you can have different types like float or arrays. (yes i know PAWN is typless but you know what i mean). If your data is all one type use arrays/vars, if not use arrays of enums.
Re: Enum/NormalVar -
Toreno - 13.07.2011
Quote:
Originally Posted by Roko_foko
Okay, I used to use normal variables and I am fine with them, but I think I have somewhere read that enums take less memory, what isn't logical unless it is a pointer. So I am asking is it worth to learn about enums since I am satisfied with normal Vars
|
I'm not saying it's hard to work with variables, I meant, it's too much variables and dumb to do when you can easily store them into an enum which works with one varaiable or however it works, leave the memroy and enum isn't that hard to learn, here are tutorials.
https://sampwiki.blast.hk/wiki/Keywords:Initialisers#enum
Re: Enum/NormalVar -
Trotty729 - 13.07.2011
personaly what i recomend is which you prefer

i use normal variables
Re: Enum/NormalVar -
Roko_foko - 13.07.2011
Quote:
Originally Posted by iggy1
Enums are often better to use because you can have different types like float or arrays. (yes i know PAWN is typless but you know what i mean). If your data is all one type use arrays/vars, if not use arrays of enums.
|
You can have different types like float or arrays without enums aswell.
pawn Код:
new Float:Var1, Var2[10], Var3;
You can use both, but is it true that enums take less memory?
Re: Enum/NormalVar -
iggy1 - 13.07.2011
PAWN uses cells only, so the size will be the same as its counterpart. Arrays of enums (IMO) are a lot easier to work with than several different variables. Like someone said before use what you prefer.