PDA

View Full Version : Enum for all dialogs? Instead of ids?


RyanDam
06/02/2013, 05:34 PM
Hello,

Im sick of all these IDs and defining them is also a pain in the ass. So I was wondering, if I could make a enum with names only? and use that as reference?

Is that good as the other methods?

Scenario
06/02/2013, 05:40 PM
enum eDialogs
{
diagAuthentication,
diagRegistration,
diagRegConfirmation,
diagReportLog,
diagCMDS,
diagACMDS
};

You can basically just add to the enum and use the define straight away. So if I wanted to add a new dialog, diagHelp, I would just add "diagHelp" under "diagACMDS" and I can immediately start using diagHelp w/o dealing with any dialog numbers.

Misiur
06/02/2013, 05:42 PM
enum {
D_LOGIN,
D_REGISTER
}
//Which is in this case equivalent to:
#define D_LOGIN 0
#define D_REGISTER 1

Wiki shows usage of enums as well: http://wiki.sa-mp.com/wiki/ShowPlayerDialog

Check out this thread about enums for more info:
http://forum.sa-mp.com/showthread.php?t=318307

DXM
06/02/2013, 05:47 PM
No, bad...

enum (+= 1) {
d_none, // 0
d_login = 1, // 1
d_register // 2 (others +1)
};

Use:

// spd
ShowPlayerDialog (playerid, d_login, ...);
// or
if (dialogid == d_login) { }