[Tutorial] How to use enums [ BASICS]
#1

Basically in this tutorial, I'm going to show you how to use enums, for example.

If you want to create a small register script insted of having lots of arrays like this:

pawn Код:
new username[MAX_PLAYERS][24];
new password[MAX_PLAYERS][24];
new adminlevel[MAX_PLAYERS];
It will turn to this
pawn Код:
UserStats[playerid][AdminLevel] = 1234;
To start off: you must create the enum:
pawn Код:
enum pInfo {
With pInfo being the name of the enum:
pawn Код:
enum pInfo {
Username[24],
Password[40],
AdminLevel
}
Now you are all set you must create a array which holds the enum:
pawn Код:
new UserStats[MAX_PLAYERS][pInfo];
Then later on you can use the enum as it will work eg:
pawn Код:
UserStats[playerid][AdminLevel] = 1;
That way it gets stored in the enum but still saves time insted of doing a new variable for each.


If you have any questions feel free to ask.

Kyle
Reply


Messages In This Thread
How to use enums [ BASICS] - by Kyle - 10.09.2011, 22:10
Re: How to use enums [ BASICS] - by PrawkC - 10.09.2011, 22:13
Re: How to use enums [ BASICS] - by FireCat - 10.09.2011, 22:17
Re: How to use enums [ BASICS] - by Kyle - 10.09.2011, 22:21
Re: How to use enums [ BASICS] - by Zh3r0 - 10.09.2011, 22:39
Re: How to use enums [ BASICS] - by [M]onsieur - 10.09.2011, 22:43
Re: How to use enums [ BASICS] - by Kyle - 10.09.2011, 23:01
Re: How to use enums [ BASICS] - by Zh3r0 - 10.09.2011, 23:06
Re: How to use enums [ BASICS] - by Lorenc_ - 11.09.2011, 01:17
Re: How to use enums [ BASICS] - by Ehab1911 - 13.09.2011, 11:16

Forum Jump:


Users browsing this thread: 1 Guest(s)