SA-MP Forums Archive
Enum for all dialogs? Instead of ids? - 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)
+--- Thread: Enum for all dialogs? Instead of ids? (/showthread.php?tid=413760)



Enum for all dialogs? Instead of ids? - RyanDam - 06.02.2013

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?


Re: Enum for all dialogs? Instead of ids? - Scenario - 06.02.2013

pawn Код:
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.


Re: Enum for all dialogs? Instead of ids? - Misiur - 06.02.2013

pawn Код:
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: https://sampwiki.blast.hk/wiki/ShowPlayerDialog

Check out this thread about enums for more info:
https://sampforum.blast.hk/showthread.php?tid=318307


Re: Enum for all dialogs? Instead of ids? - DXM - 06.02.2013

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) { }