[TUT] Enumerations (enum)
Introduction:
Enumerations are basically data structures. Basic Syntax: The basic syntax for enumerations is as follows: Creating Tags: Creating your own tags is easy. Using Tags on Variables: Using tags is simple. If you've worked with bools or Floats in AMXX before, then you have used tags before. Constants: Enumerations can be useful to create a list of constants without having to define each one. Data structures: Data structures allow you to put different types of data in an array.I think this tutorial is complete. If I confused any information or left anything out, please let me know. Feedback and suggestions are welcome. |
Re: [TUT] Enumerations (enum)
Good job, Exolent. I feel like a lot of people don't fully understand how much is capable with enum and this should definitely help.
However, whenever I get a question about enumerations I like to show them the CsTeams enum to show them how it would be set up and used, since many people are familiar with the functionality of the CsTeams tagging and constants. Perhaps you could show that as an example, some might understand its practical capabilities this way. |
Re: [TUT] Enumerations (enum)
gj. Nice Tut Exolent
|
Re: [TUT] Enumerations (enum)
thanks for sharing! :)
|
Re: [TUT] Enumerations (enum)
Thnx Again X-0lent !
PS: Atleast make the tutorial a little colorful like bugsy's bits tutorial |
Re: [TUT] Enumerations (enum)
That's not complete and there are few things to say :
- You don't talk about weak (lower case letter) and strong tag (upper case letter). The weak tag can be dropped implicitly in some situations. Check the pawn language guide to get more informations. - Stop to cast the tags in your examples. At least the 3 first, there is no reason to cast. - I would like to see an example with tagName + IncrementType. - Don't say random things like "If the above code gives a tag mismatch warning[...]" ; When you set a value, which is important is the tag of the var (g_ePlayerData). When you get a value which is important is the tag of the item (Player_Speed). g_ePlayerData is untag, so if you try to set a value with a strong tag, you will get an error. If the tag was weak or if the the var (g_ePlayerData) was tagged with the same tag as the value you want to set, you won't get errors. In the next example when you get the value, since Player_Speed is a fload and since 250.0 too, the tag is the same, no error and no need to specify Float:. - I don't see the point to show "Method #1:". Explaining the size it's ok, but showing an example is really a bad idea. It's confusing and you should avoid to show weird ways. - ePlayerData[ Player_Speed ] = 250.0 ; should be casted. - There is no example with custom tags. - There is no example with structure inside a structure. - In your last example, the problem can be simply solved by using a weak tag. The tag will be dropped automatically. Here an old thread you may find some ideas |
Re: [TUT] Enumerations (enum)
If I go with HN, shouldn't members of enumeration be prefixed with m_?
PHP Code:
PHP Code:
|
Re: [TUT] Enumerations (enum)
It doesn't matter, and it's up to the coders.
|
Re: [TUT] Enumerations (enum)
But how would it be done in, let's say C[++] by a hardcore HN coder?
|
Re: [TUT] Enumerations (enum)
That's not related to the subject. I don't see the point to talk about that. See yourself in the HLSDK or whatever. Coders are free to choose the style they want to their plugins.
|
All times are GMT -4. The time now is 12:39. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.